Skip to content

Instantly share code, notes, and snippets.

@sstephenson
Created March 13, 2010 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sstephenson/331567 to your computer and use it in GitHub Desktop.
Save sstephenson/331567 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
function resolve_symlink() {
local result=`readlink $1`
[ -z $result ] && echo $1 || $0 $result
}
function expand_path() {
cd -qP $1
pwd
cd -q -
}
# Ruby equivalent: puts File.dirname(File.expand_path(__FILE__))
expand_path $( dirname $( resolve_symlink $0 ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment