A Dev Community
If you spend a lot of time in the terminal you’ll find that you write some commands very often. It is a good idea to add some shortcuts to some commands so that you can do less typing and be more efficient in your command line interface (cli). Using a .bashrc you can set some aliases for commands to save yourself some time.
.bashrc is a shell script that Bash runs whenver it is started interactively. If you have some aliases in your bashrc file they’ll be available to you to use in your cli. The first thing you’ll want to do is to make sure your .bashrc file is getting loaded. If you’re running a mac, it is quite possible that you don’t have a .bashrc file, but have a .bash_profile file which gets loaded and is a login shell. Your bash_profile should have a line like this:
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
If you don’t have that line be sure to add it. That way you can consolidate all your commands into your .bashrc file. Now you can add some handy aliases to your .bashrc file:
# colorize grep output alias grep='grep --color=auto -n' alias c='clear' alias back='cd -' alias ..='cd ..' alias ...='cd ../../' alias reload='source .bash_profile' # start a new branch alias new='git checkout -b' # remove all the annoying .DS_Store files alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
I highly recommend you check out Oh My Zsh and also our post Terminal History Auto Suggestions As You Type With Oh My Zsh. Read more about it here
Create your free account to unlock your custom reading experience.