Bash alias

Organize Aliases #

Bash aliases are usefull, but you have to keep them organized. This can be done easily, if you use a separate file for all your aliases. Add the following block to the ~/.bashrc

# Add bash aliases.
if [ -f ~/.bash_aliases ]; then
  source ~/.bash_aliases
fi

now you can add aliases to ~/.bash_aliases

The following example adds an alias to activate python environments

echo "alias activate=". ../.env/bin/activate" >> ~/.bash_aliases

Excerpt of my alias file #

# show the IPv4 IP my internet service provider assigned to me
alias myip='dig +short myip.opendns.com @resolver1.opendns.com'

# Activate Python Virtualenv
# create this with mkdir .env && python3 -m venv .env
alias activate=". ../.env/bin/activate"

# common ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

# create a directory with the current date here
alias mkdatedir='mkdir `date --iso`'