Skip to content

Instantly share code, notes, and snippets.

@kch
Created January 3, 2010 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kch/267759 to your computer and use it in GitHub Desktop.
Save kch/267759 to your computer and use it in GitHub Desktop.
Awesome bash functions for the mac-minded
# Allows gnu du to accept bsd's du -d option by wrapping
# gdu and translating -d to --max-depth before calling it.
# Useful on linux and solaris
du --help 2>&1 | grep -q -- '-d depth' || du () {
args=`echo "$@" | perl -pe 's/(-\w*)d(\d+)\b/$1 --max-depth=$2/'`
gnu_du=`which gdu du 2>/dev/null | head -1`
"$gnu_du" $args
}
egem () { $EDITOR $(dirname `gem which $@`)/..; } # opens a gem directory in $EDITOR
tman () { MANWIDTH=100 MANPAGER='col -bx' man $@ | mate; } # opens a man page in TextMate
O () { open ${@:-.}; } # opens current dir or argument in the Finder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment