DEV Community

Shubhashish Dixit
Shubhashish Dixit

Posted on

What's a CLI, Alias and how to make one? Aliases every developer uses these days.

Newcomers read along the article and learn in the boring detail.

TL;DR below.

Do you use CLI?!

Like come on CLI is awesome, it gets so much sh*t done for us. For the new comers in the CLI world, WELCOME! the road ahead is pretty crappy, you won't like it at first but hey it gives you the "Hackerman feeling" you've all been trying to feel since you were kids.

What's CLI if you'd ask?

Well its a command line program that accepts text input to execute operating system functions..... uggh kill me already.
this thingy right here

yes this very thing

Now what the frack is an alias anyway?

You have been using it without knowing it.
If you have written a program you would have encountered, the windows user command prompt, linux users terminal, mac users the terminal app.

Hey Linux and Mac people, ever seen this thingy ~
Let me remind you because I know you have,
cd ~/Downloads/or_some_place_else yeah that ~ is the same as
cd /home/user/Downloads/or_some_place_else

Get It?

~ == /home/users

that exactly right there is an alias.

Alright you'll encounter them a lot.
Let's starting using them anyway and learn how to make our own!!

How to make an alias??

NOTE: Please learn what are shells and which one are you using and which one should you use right here

alias command_name="command";

# open your .<shell>rc file, (meaning .bashrc or .zshrc)
# start typing
# just write alias and then the shell command right along the '=' sign.

alias gp=git pull;

# you guessed it, gp would now act as our normal git pull command. 

# FAQs
# is ; neccessary? yes for now. you'd know when to use it and when not  # on you own.

Can we write absolutely just once command per alias name?

NOOOO, you can write as many as you'd like!!

# here let's make a function where you could make a directory and
# directly change directory to it, which means.. make a directory
# and go into it.

alias mc='func(){ mkdir -p "$1"; cd "$1" }; func '

# FAQs
# could we not do it without a function?
# nope, not if you'd like to keep the directory name according to you.

Now go on and make your own aliases as many as you'd like :)

Go ahead and read all types of aliasing as use them, some of them stand below.



#git add . && git commit 'message' && git push origin master
# usuage: gac 'added files' 
function gac(){
        git add .;
        git commit -m "$1";
        git push -u origin master;

# fast find
alias ff=find . -name $1;

#make a dir and cd into it
alias mc='bar(){ mkdir -p "$1"; cd "$1" }; bar '

# change directories
alias ..= cd ..;
alias ...= cd ../..;
alias ....= cd ../../..;   
alias .....= cd ../../../..;

# smart ls
alias l=ls -lah;

# package manager
# ubuntu people
alias sad='sudo apt-get';
# fedora people
alias df='sudo dnf';
# i use arch btw people
alias pc='sudo pacman';
# am i rich? heheheheheh(laughs in gold), mac people
alias bb='brew install'

#ip address
alias myip="curl; echo" 

#public ip address
alias mypip='curl'

alias update='sudo apt-get update && sudo apt-get upgrade'

You may find these explained aliases in detail of great help here:

GitHub logo algotech / dotaliases

Helpful bash aliases for true professionals.


If you use the terminal on a daily basis, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to execute your commands with only a few keystrokes that ultimately get hardcoded into muscle memory.

This repository is an easy to install project that contains a growing list of aliases for different frameworks and tools that works on any *nix system.

The project was started with passion by the Algotech Software Engineering Team.

Aliases list

Bash aliases




Article Inspiration: Click just right here

If you read the whole thing, YOU'RE AWESOME!


Top comments (1)

x1k profile image
Asaju Enitan

Thanks for this, you just saved me multiple times.