-
-
Save jeeger/6020a28625f147e4236d1ff0d08ace34 to your computer and use it in GitHub Desktop.
ZSH persistent directory aliases
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
if which sponge &>/dev/null; then | |
qjc() { | |
ALIAS="$1" | |
DIR="$(pwd)" | |
hash -d "$1"="$DIR" | |
echo "hash -d \"$1\"=\"$DIR\"" >> ~/.zsh/dirhashes | |
} | |
qjd() { | |
if [[ -z "$1" ]]; then | |
DIR=$(pwd) | |
grep -v "hash -d \".*\"=\"$DIR\"" ~/.zsh/dirhashes | sponge ~/.zsh/dirhashes | |
else | |
ALIAS="$1" | |
grep -vF "hash -d \"$ALIAS\"" ~/.zsh/dirhashes | sponge ~/.zsh/dirhashes | |
fi | |
hash -rd | |
source ~/.zsh/dirhashes | |
} | |
qjl() { | |
sed -n '/^hash/ { s/hash -d "\([^"]*\)"="\([^"]*\)"/\1: \2/g p }' < ~/.zsh/dirhashes | |
} | |
source ~/.zsh/dirhashes | |
else | |
echo "Sponge not found, dirhash functionality not available. Install moreutils." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added functionality to delete alias for pwd.