Created
October 19, 2018 14:33
-
-
Save DanLaufer/f12c1ed83c4e23f4913c92221efd4d6e to your computer and use it in GitHub Desktop.
Bash - Function add aliases
This file contains hidden or 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
# this command will add an alias and source the .zshrc | |
# $1 is the keys for the alias | |
# $2 is what will run. Put in quotes. | |
function newalias | |
{ | |
if [ "$1" != "" ] && [ "$2" != "" ]; then | |
echo 'alias '$1'='"\""$2"\"" >> ~/.zshrc | |
alias "$1"="$2" | |
else | |
echo "The newalias command takes two arguments as follows: newalias <alias command> <alias function, in double quotes>" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment