mac

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 https://brew.sh
# install dos2unix
$ brew install dos2unix
# use dos2unix
$ 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"