Created
December 3, 2012 21:30
-
-
Save yonchu/4198256 to your computer and use it in GitHub Desktop.
zshでよく使うディレクトリにエイリアスを設定(~/.zshrcに設定して利用します)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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