DEV Community

Cover image for Bash/Zsh aliases every developer should use
Sandip Rana
Sandip Rana

Posted on

Bash/Zsh aliases every developer should use

Are you tired of typing lengthy commands in your terminal every time you perform routine tasks? Bash aliases can be a lifesaver,Here's a quick guide on how to add custom aliases in Bash/Zsh:

Open your configuration file:

nvim ~/.zshrc
nvim ~/.bashrc
gedit ~/.zshrc
gedit ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Try any of the above command based on your terminal, use nvim if neovim is installed else use gedit for ease of use.

Choose Your Alias: Decide on a short, memorable name for your alias. It's best to avoid overwriting existing commands to prevent confusion.

Add the Alias: Once you've chosen a name, you can add your alias to the configuration file. Use the following syntax
alias your_alias_name='your_command'
Replace your_alias_name with the name you chose and your_command with the command or series of commands you want to alias. Don't forget to enclose the command in single quotes.

Save and Close the File: After adding your alias, save the changes and close the configuration file.

Reload the Configuration: To apply the changes without restarting your terminal, you need to reload the Bash configuration. You can do this by running:

source ~/.bashrc
source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Once you've reloaded the configuration, test your alias by typing it into the terminal. If configured correctly, it should execute the associated command(s).

Some of the aliases example you can use for your everyday routine

alias Gs='git status'
alias gcm='git commit -m'
alias gmo='git merge origin'
alias gmf='git merge --no-ff'
alias gp='git pull origin'
alias gnb='git checkout -b'
alias gc='git checkout'
alias clr='clear'
alias update='sudo apt-get update'
alias upgrade='sudo apt-get upgrade'
alias package='sudo dpkg -i'
alias install='clear; npm install'
alias start='clear; npm start'
alias 14="nvm use 14"
alias 16="nvm use 16"
Enter fullscreen mode Exit fullscreen mode

Now, whenever you type clr into your terminal and hit Enter, it will clear the screen.

By creating custom aliases, you can significantly enhance your productivity in the terminal, saving time and reducing the likelihood of typing errors. Experiment with different aliases to tailor your terminal experience to your workflow. Happy aliasing! 🚀

Top comments (0)