Speed Up Your CLI with Aliases

The command line is a powerful tool for developers, sysadmins, and tech enthusiasts. Aliases can significantly enhance your efficiency by shortening long commands and grouping common tasks. In this blog post, we'll explore some practical and time-saving Bash aliases.

Why Use Aliases?

Aliases are shortcuts for longer commands. They save time, reduce typing errors, and make your workflow smoother. Here's a collection of useful aliases to streamline your command line experience.

Basic Aliases

1. Clearing the Terminal:

alias c='clear'

A simple alias to clear the terminal screen quickly.

2. Git Shortcuts:

alias g='git'

Shorten git commands to a single letter for rapid version control operations.

3. List Directory Contents:

alias l='exa -lars date'

Use exa instead of ls for enhanced directory listing with sorting by date.

4. System Information:

alias nf='neofetch'

Quickly display system information with Neofetch.

File and Directory Management

5. Move Files to Temporary Directory:

alias rmv='mv -t /tmp '

Safely move files to the /tmp directory instead of deleting them.

6. Neovim Shortcuts:

alias v='nvim'
alias vi='nvim'

Open files with Neovim using v or vi.

7. Create Directories with Parents:

alias mkdir='mkdir -pv'

Create directories with all necessary parent directories.

8. Python Environment Activation:

alias pyenv='source /home/web/pyenv/bin/activate'

Quickly activate your Python virtual environment.

User and System Commands

9. Switch to Web User:

alias web='su - web'

Switch to the web user with a single command.

10. Edit Files with Sudo:

alias svi='sudo vi'

Edit files with root privileges using Neovim.

11. Systemctl Shortcuts:

alias ss='sudo systemctl'

Manage system services easily with systemctl.

12. Python 3 Shortcut:

alias p='python3'

Run Python 3 scripts without typing the full command.

Directory Navigation

Navigating directories can be tedious. These aliases help you move up directories quickly:

13. Go Up One Level:

alias ..='cd ..'

14. Go Up Two Levels:

alias ...='cd ../../../'

15. Go Up Three Levels:

alias ....='cd ../../../../'

16. Go Up Four Levels:

alias .4='cd ../../../../'

17. Go Up Five Levels:

alias .5='cd ../../../../..'

Archive Extraction

Extracting different types of archives can be cumbersome. This function makes it easier:

18. Extract Files:

ex () {
  if [ -f $1 ] ; then
    case $1 in
      *.tar.bz2)   tar xjf $1   ;;
      *.tar.gz)    tar xzf $1   ;;
      *.bz2)       bunzip2 $1   ;;
      *.rar)       unrar x $1   ;;
      *.gz)        gunzip $1    ;;
      *.tar)       tar xf $1    ;;
      *.tbz2)      tar xjf $1   ;;
      *.tgz)       tar xzf $1   ;;
      *.zip)       unzip $1     ;;
      *.Z)         uncompress $1;;
      *.7z)        7z x $1      ;;
      *.deb)       ar x $1      ;;
      *.tar.xz)    tar xf $1    ;;
      *.tar.zst)   unzstd $1    ;;      
      *)           echo "'$1' cannot be extracted via ex()" ;;
    echo "'$1' is not a valid file"

This function detects the file type and uses the appropriate command to extract it. Simply call ex <file> to extract your archives.


These aliases and functions can drastically improve your command line efficiency. Customize them to fit your workflow and enjoy a more streamlined and productive terminal experience. Happy aliasing!

My personal aliases : GITLAB alias

By implementing these aliases, you can make your command line interactions faster and more efficient. Try them out, modify them to your liking, and share your favorite aliases in the comments!

# Last updated on .