HOW TO: Create Time-Saving Aliases

save your precious time with command line aliases

If you don’t often use the terminal, but you find yourself having to type the same commands over and over, here’s a tip for you: create aliases. What’s an alias? It’s a shortcut that will save you time.

NOTE: this “trick” works exactly the same on Linux. But I’m assuming that, if you’re using Linux, you already know about aliases.

For example, if you use macOS and Homebrew every once in a while you need to update homebrew and upgrade your formulas. So you will need to type brew update && brew upgrade && brew cask upgrade. That takes time. But you can create an alias, a “shortcut” command that can consist of just one letter or word that will perform the same commands.

Makes sense? Let’s say you will set brew as an alias for brew update && brew upgrade && brew cask upgrade. Now when you want to update and upgrade homebrew, instead of executing that long line of multiple commands ( or executing them one by one ) all you have to do is execute brew.

Ok so how do you create an alias? You will need to edit your bashrc or zshrc file. If you don’t know which one you need to edit, you’re using the default shell which is bash. But just to be sure, open up your terminal and type echo "$SHELL" .

Now you can edit the bashrch file directly from the terminal with nano ~/.bashrc or just open the file with a text editor. The file is located in your Home folder but it’s hidden. Here’s how to quickly toggle the visibility of hidden files in macOS.

Now just add your alias like this: alias='your-long-command' and save the file. Example: alias brew='brew update && brew upgrade && brew cask upgrade'

It’s that simple. Now, when you need to use the terminal, you can be so much faster and productive. Here’s a few aliases that I personally use and you might find useful:

alias c='clear' - clear terminal output and clear screen
alias r='reset' - reset terminal
alias ls='ls -lG' - list files and directories with long listing and showing file type and  permissions
alias purge='sudo purge' - clear RAM
alias dns='sudo killall -HUP mDNSResponder' - flush dns cache
alias ip='curl ifconfig.co && curl ifconfig.co/country && curl ifconfig.co/country-iso && curl ifconfig.co/city && curl ifconfig.co/asn'  - get IP 

SUPPORT




Liberapay  
Bitcoin (BTC) 1Hfuq77gKKFJeNcq4EP4dQK3yDRWrFEwJR
Bitcoin Cash (BCH) qzmdm6e6q5wf2p6sxz2mst7cenz60newwc5m4e9js8
Ether (ETH) 0x5f02869278C24A6579d3820f52AD15936D6F9d69
Stellar (XLM) GDWT2QU2CI3GZ5XH5DTSU3IUAHZMTB6VQKKRHBYWS5YCCQOAG6OKG2OB
More content?