Customize your terminal with aliases

To beginners, the terminal looks like a scary place. I remember what I was thinking when I was watched developers use the dark looking box with text. It felt complicated and there was a lot of gibberish! I asked “What do you use the terminal for?” And the developer responded, “I use it to navigate to different directories — folders”.

I said, “Why can’t you just click?”

“It’s faster.”

And I thought, how do you even know where you are going?

Recognizing the disbelief on my face, he said “It’s easier to install stuff. Like if I want something, I just go ‘sudo apt-get or pip install’.”

“But, how do you know — like — know what to type?”

And then he went on to show me how he googles a python package and instructions on the top say ‘pip install this.’ It still looked like a dark and complicated place that impressed me when I saw someone in it. I go, “Omg you’re a real hacker~~”

These days I can’t feel any more differently about the terminal. It feels like home. Like you’re finally in a quiet place and you can think in peace. How did it get from feeling scared to loving it? Stockholm’s syndrome, maybe. Or these few commands:

  • “cd <directory>” -> changes directory
  • “cd ..” -> goes up one directory
  • “ls” -> lists all the files and folders in the current directory
  • “cat <filename>” -> quickly view the contents of a single file
  • “nano <filename>” -> quick text editor

In addition to the above, I also regular use a few handy terminal commands like:

  • “find / -name <filename>” -> I use this when I don’t know where the file lives. I just want it to search the entire machine.

Meta Analysis

Improve it with aliases

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

To create your own alias, go to your root directory. In your terminal, you can simple type in “cd” and you will be tossed into your root directory designated by a tilda (~) symbol. Now you can view all the files there with ls . The file we are going to edit is in here but you can’t see it with a simple ls , you need ls -a to view .bash_profile .

Is the file there? If not, do not worry. We will create one. Enter: nano .bash_profile It will open up the terminal text editor. If the files doesn’t exist, it will create one.

An alias is designated with the term “alias” in front of it. Then, enter the shortcut you’ll like to type. And then, enter the long form of the command separated with an equal (=) sign.

Now, when I type .. I will go up one directory. ... will go up two directories.

Alias for one directory

Alias for scripts

alias startgetmypup='cd ~/Documents/code/dog-shelter-app; python3 app.py';

I fit two long commands into one alias.

Aliases for Django

  1. pipenv run ./manage.py makemigrations
  2. pipenv run ./manage.py migrate
  3. pipenv run ./manage.py runserver

Now, it’s pmm, pm, pr. Or even faster, pmr.

alias pp='pipenv run ./manage.py';alias pmm='pp makemigrations';alias pm='pp migrate';alias pr='pp runserver';alias pmr='pp makemigrations; pp migrate; pp runserver';

If you are wondering why programmers put so much effort into jazzing up the terminal, I think we are trying to streamline all the distractions. I personally have a monkey mind. I struggle with staying focused (and off reddit). I personally don’t like spending a lot of time searching for a file or scanning directories to see if it is the right now. Those extra seconds add up. It’s a two edged blade because I lose traction when I spend too much just looking.

Colors!

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "export CLICOLOR=1export LSCOLORS=Fxfxcxdxbxegedabagacadalias ls='ls -Fh'

Use this handy tool to pick and generate your own LSCOLORS codes.

Terminal Tools

The terminal feels like home.

Software Engineer — Blockchain, Cybersecurity, and Commercial Space