Skip to content

Instantly share code, notes, and snippets.

@connormckelvey
Last active August 29, 2015 13:56
Show Gist options
  • Save connormckelvey/9275367 to your computer and use it in GitHub Desktop.
Save connormckelvey/9275367 to your computer and use it in GitHub Desktop.
Bash Function for adding new aliases
#add alias
function newalias() {
echo alias $1=\"$2\" >> ~/.aliases
source ~/.bash_profile
}
@connormckelvey
Copy link
Author

I was sick of opening vim to add an alias, closing and then reloading .bash_profile so here is a nice function that does it for you.

If you don't store you aliases in a separate file (Which I recommend doing) then be sure to change .aliases to .bash_profile.

Function is called like so:
newalias 'test' 'echo test'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment