Skip to content

mac and macos

use vscode code command on terminal without admin rights

add this to your .zshrc

code () { VSCODE_CWD="$PWD" open -n -b "" --args $* ;}

set a mac mini to turn on after a power failure without macos

if using linux on a mac mini hardware, search for a LPC controller

sudo lspci | grep LPC

set the auto start flag on this controller

sudo setpci -s 00:1f.0 0xa4.b=0

if needed, search for the right flag on this datasheet.

resizing an sparseimage

first, unmount the image if in use.

to increase the image size to 50Gb:

hdiutil resize -size 50g filename.sparseimage

to shrink the image size:

hdiutil compact filename.sparseimage

reference: Sparse image Wikipedia article

find a file encoding

$ file -I original.csv
original.csv: text/plain; charset=iso-8859-1

convert file to another encoding

iconv -f iso-8859-1 -t utf-8 < original.csv > copy.csv

remove windows line breaks

install homebrew. follow the instructions on

after that, use homebrew to install dos2unix

brew install dos2unix

and use it

dos2unix original.csv

rebuild the spotlight index

sudo mdutil -E /

what the -E option does?

     -E  This flag will cause each local
         store for the volumes indicated to
         be erased.  The stores will be
         rebuilt if appropriate.

remove duplicated entries in the open with list

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

reference: Rebuild LaunchServices to Fix Duplicate Entries in OS X’s ‘Open With’ Menu

add a directory to the $PATH

on mac os there's a directory called /etc/paths.d. inside that, the path_helper utility add the reference to all directories used on $PATH.

to add any directory to /etc/paths.d:

sudo -s 'echo "/my/new/path" > /etc/paths.d/my'

pay attention: the files inside /etc/pths.d can't have empty line endings.

reference: Mac OS X: Set / Change $PATH Variable

run more than one instance of an app

open -n -a "app name"