Useful Terminal Tips

If you are like me, you use the command line daily and like any tool that you use for many tasks, it's worth spending time learning how to use them. The following are some quick tips to improve your command line experience.

Keyboard Shortcuts

  • ctrl-r : history search commands
  • ctrl-a : go to beginning of line
  • ctrl-e : go to end of line
  • ctrl-u : delete everything BEFORE the cursor
  • ctrl-k : delete everything AFTER the cursor

Must-have Tools

dotfiles

dotfiles is commonly referred to repositories that store your terminal environment settings. This can be a huge time-saver when you are getting your terminal environment up and running.

For more information and inspiration, visit https://dotfiles.github.io/

Or you can look at my dotfiles

Other Tips

  1. create aliases for everything in ~/.bashrc to speed things up
  2. echo $? : show the exit code of my last command.
  3. sudo !! : run the previous command as sudo (so useful when you forgot to sudo a long command)

Using the caret (^) character to correct mistakes.

Imagine you write something like this: npm i eslunt

You wanted eslint, not eslunt! Easy fix: ^eslunt^eslint

This is especially useful if you are passing multiple arguments on your command.

ctrl+r for reverse searching of previous command

add a "# tags" at any commands end to use above for future. Lets say you have a ssh into multiple servers

  • $ ssh -Uasfd host1 # server1
  • $ ssh -Uaiouhqe host2 # server2 then later, ctrl+r -> and type ver1

Update: Even More Tips and Tools

Who Am I?

My name is Omar Martinez. I’m a Lead Frontend Software Developer based out of Seattle. I've been a developer professionally for 16 years. I’ve been known as a “Jack of All Trades”. I work most of the time in JavaScript. This site is an attempt to share my thoughts and learnings. I love technology, music and video games. My dream job is to be a DJ 🖤🎧.

2022