Skip to content

Bash Aliases

Aliases are shortcut commands that expand into longer commands when you type them. Adding them to ~/.bashrc ensures they are loaded automatically on every new shell session.

Add your aliases at the end of the file to keep them easy to find.

Terminal window
nano ~/.bashrc

Scroll to the bottom of the file and add your aliases. The example below defines a shortcut for activating a Python virtual environment in the current directory.

Terminal window
# Activate the Python virtual environment in the current directory
alias activate='source .venv/bin/activate'

New shell sessions pick up the changes automatically. To use the aliases in your current terminal without opening a new one, source ~/.bashrc manually.

Terminal window
source ~/.bashrc

Navigate to any project directory that contains a .venv folder and run the alias.

Terminal window
cd ~/projects/my-project
activate

To see all aliases currently active in your session run:

Terminal window
alias

To filter only the custom aliases you added to ~/.bashrc:

Terminal window
grep '^alias ' ~/.bashrc