Skip to content

Instantly share code, notes, and snippets.

@DanLaufer
Created October 19, 2018 14:33
Show Gist options
  • Save DanLaufer/f12c1ed83c4e23f4913c92221efd4d6e to your computer and use it in GitHub Desktop.
Save DanLaufer/f12c1ed83c4e23f4913c92221efd4d6e to your computer and use it in GitHub Desktop.
Bash - Function add aliases
# 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