Skip to content

Instantly share code, notes, and snippets.

@cyx
Forked from sstephenson/gist:331567
Created March 13, 2010 22:26
Show Gist options
  • Save cyx/331599 to your computer and use it in GitHub Desktop.
Save cyx/331599 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