DEV Community

Paul Bennett
Paul Bennett

Posted on

Awesome aliases make everything better

I bloody love using aliases within my terminal. It does make everything better, as I have grown more confident using the terminal. I have continued to add more and more aliases, solely to make my workflow quicker.

Below I have put all my aliases that are currently in my .zshconfig file. I am sure more will be added over time. I have various ones for Python, Django, Gatsby and Git. The Python ones have made my workflow so much easier, especially when running virtual environments. Just a couple are:

Running a Python script

Before:

$ python <python-file>
Enter fullscreen mode Exit fullscreen mode

After

$ p <python-file>
Enter fullscreen mode Exit fullscreen mode

Installing Python packages

Before:

$ pipenv install <python-package>
Enter fullscreen mode Exit fullscreen mode

After:

$ pi <python-package>
Enter fullscreen mode Exit fullscreen mode

Switching Git branches

Before:

$ git switch <branch-name>
Enter fullscreen mode Exit fullscreen mode

After:

$ gbs <branch-name>
Enter fullscreen mode Exit fullscreen mode

The above are only small changes, but they will make a tonne of difference especially if you're having to frequently type the same commands. Take a look at the list before hopefully, you can get some inspiration from them.

If you're using ohmyzsh you can check out their aliases here.

alias zshconfig="code ~/.zshrc"
alias ohmyzsh="code ~/.oh-my-zsh"

alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."

# Shortcuts
alias dt="cd ~/Desktop" 
alias dev="cd ~/Developer"
alias dl="cd ~/Downloads"

# Git Shortcuts
alias gs="git status"
alias gp="git pull"
alias gb="git branch $1"
alias gbs="git switch $1"
alias ga="git add ."
alias gc="git commit -m $1"
alias gca="git commit -a -m $1"
alias gpo="git push origin $1"

# Python Shortcuts
alias python="/usr/local/bin/python3"
alias pip="pip3"
alias p="python $1" # saves typing python every time.
alias pi="pipenv install $1" # allows you to just type the package
alias ps="pipenv shell" # start a env with just "ps"

# Flask Shortcuts
alias fr="flask run" # start a flask app

# Django Shortcuts
alias rs="python manage.py runserver" # starts django server
alias dmm="python manage.py makemigrations" # makes db migrations in django
alias dm="python manage.py migrate" # migrates db in django

# Gatsby Shortcuts
alias gd="gatsby develop"
alias gbd="gatsby build"

# opens VSC from the cmd line:
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)