Created
January 5, 2016 14:09
-
-
Save prathik/7ba3e7e9933063d7f7a4 to your computer and use it in GitHub Desktop.
create alias, make alias and remove alias shortcut for zsh
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
alias showalias='cat ~/.zsh_alias' | |
#Add source ~/.zsh_alias in your ~/.zshrc | |
#Type ma <aliasname> in a directory and it will create an alias to cd into that directory | |
makeAlias() | |
{ | |
curDir=`pwd` | |
echo "alias $1='cd $curDir'" >> ~/.zsh_alias | |
source ~/.zshrc | |
} | |
# ca "aliasname='<command>'" creates an alias aliasname for the command given | |
customAlias() | |
{ | |
storeString="alias $1" | |
echo $storeString | |
read -p "Do you wish to save this alias? [y/n]" yn | |
if [ "$yn" = "y" ]; then | |
echo $storeString>> ~/.zsh_alias; | |
source ~/.zshrc; | |
fi | |
} | |
# ra aliasname removes the alias | |
removeAlias() | |
{ | |
sed -i "/^alias $1/d" ~/.zsh_alias; | |
unalias $1; | |
source ~/.zshrc; | |
} | |
alias ma=makeAlias | |
alias ca=customAlias | |
alias ra=removeAlias | |
#To see the expansion of an alias use `type <alias>` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment