Skip to content

Instantly share code, notes, and snippets.

@yonchu
Created December 3, 2012 21:30
Show Gist options
  • Save yonchu/4198256 to your computer and use it in GitHub Desktop.
Save yonchu/4198256 to your computer and use it in GitHub Desktop.
zshでよく使うディレクトリにエイリアスを設定(~/.zshrcに設定して利用します)
### Directory aliases
# e.x.
# $ hash -d hoge=/to/path
# $ ls ~hoge
set_hash_in_links() {
local links=~/links
[ ! -d "$links" ] && return 0
[ $(command ls -1 "$links" | wc -l) -eq 0 ] && return 0
local src
local target
for target in "$links"/*; do
src=$(basename "$target")
case `uname -s` in
Darwin|FreeBSD)
target=$(readlink -n $target)
;;
*)
target=$(readlink -fq $target)
;;
esac
[ -n "$target" ] && hash -d $src="$target"
done
}
set_hash_in_links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment