What's a CLI, Alias and how to make one? Aliases every developer uses these days. 
Tags: newcomers, aliases, developers, shellcommands
Published: 2019-11-22 13:48:02

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

## [TL;DR](#TLDR) 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](https://thepracticaldev.s3.amazonaws.com/i/stdvteiuqzy5tirhnux9.jpg)


## 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]("https://www.edureka.co/blog/types-of-shells-in-linux/")

`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.

## TL; DR<a name="TLDR"></a>

```
#Aliases

#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 http://ipecho.net/plain; echo" 

#public ip address
alias mypip='curl ifconfig.me'

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

#### You may find these explained aliases in detail of great help here:
{% github https://github.com/algotech/dotaliases %}

#### Article Inspiration: [Click just right here]("https://codeburst.io/7-super-useful-aliases-to-make-your-development-life-easier-fef1ee7f9b73")


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

## Thanks!