Its so handy to execute long commands or series of commands with just a word in Unix systems like Linux, Mac, BSDs, etc. In Bash’s
~/.bashrc you can see a line like
# ~/.bash_aliases, instead of adding them here directly. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases
What it says is, you can have a file
~/.bash_aliases in which you can define alias to commands you need to run every once and while.
You can define alias like
# ~/.bash_aliases alias greproute='rake routes | grep ' alias myshortcut='cd ~/projects/myproject && bundle exec rails c'
If you wished not to update the
.bash_aliases file, you can have those lines defined in
.bashrc file itself.
Note: The above mentioned commands/procedure is not gonna work for shells other than Bourne Again Shell(Bash).
For ZShell users
~/zshrc file in
nano editor or any and paste the following line.
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
Make sure, you have followed the instruction illustrated above to define aliases and have
This works because syntax for
zsh are almost same.