Explore a few aliases you may add in ~/.bashrc when using the Bash shell as shortcuts for running longer commands.
Background
Often the ~/.bashrc file is used to automatically run Bash code within that file before launching a new Bash terminal.
There are a few lines of code I find useful to include in the ~/.bashrc file that can save some time when using Bash. These lines make use of the alias command to write shorthand versions of commands.
For example, instead of having to write out git status in my Bash shell, I can just add the following line to ~/.bashrc:
alias gs="git status"Then the next time I open a new Bash shell I should be able to execute gs to run git status.
Warning
Ensure that when you add an alias that it is not the same name as an existing command otherwise the alias may be called and not the original command.
Feel free to copy, paste, and edit the following aliases in your ~/.bashrc file.
Git aliases
These aliases are useful for running commands related to the git command-line tool used for version control:
alias gs="git status"
alias ga="git add ."
alias gc="git commit"
alias gp="git push"
alias gd="git diff"Bun aliases
These aliases are useful for running commands using the bun toolkit (often used with web development):
alias bi="bun install"
alias bd="bun dev"
alias bb="bun run build"If you use pnpm
You may alternatively replace
bunwithpnpmif using the pnpm package manager.
Download this page's content as a PDF