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.
Open ~/.bashrc
Add your aliases at the end of the file to keep them easy to find.
nano ~/.bashrcAdd aliases
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.
# Activate the Python virtual environment in the current directory
alias activate='source .venv/bin/activate'Apply to the current session
New shell sessions pick up the changes automatically. To use the aliases in your current terminal without opening a new one, source ~/.bashrc manually.
source ~/.bashrcUse the alias
Navigate to any project directory that contains a .venv folder and run the alias.
cd ~/projects/my-project
activateList your defined aliases
To see all aliases currently active in your session run:
aliasTo filter only the custom aliases you added to ~/.bashrc:
grep '^alias ' ~/.bashrc