Ctrl K

Bash Aliases

Define persistent command shortcuts directly in ~/.bashrc and source them into your shell session.

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 ~/.bashrc

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 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 ~/.bashrc

Use the alias

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

cd ~/projects/my-project
activate

List your defined aliases

To see all aliases currently active in your session run:

alias

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

grep '^alias ' ~/.bashrc