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.
Open ~/.bashrc
Section titled “Open ~/.bashrc”Add your aliases at the end of the file to keep them easy to find.
nano ~/.bashrcAdd aliases
Section titled “Add 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 directoryalias activate='source .venv/bin/activate'Apply to the current session
Section titled “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
Section titled “Use the alias”Navigate to any project directory that contains a .venv folder and run the alias.
cd ~/projects/my-projectactivateList your defined aliases
Section titled “List 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