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 commandsctrl-a
: go to beginning of linectrl-e
: go to end of linectrl-u
: delete everything BEFORE the cursorctrl-k
: delete everything AFTER the cursor
Must-have Tools
- fzf:
ctrl+r
(reverse search) on steroids (https://github.com/junegunn/fzf) - I highly encourage to install the optional tools and shortcuts, it includes to usectrl+r
- autojump (https://github.com/wting/autojump):
j foo
will jump directories to my /whatever/foo directory. - jq: (https://stedolan.github.io/jq/) - Command-line JSON processor.
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
- create aliases for everything in ~/.bashrc to speed things up
echo $?
: show the exit code of my last command.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
- For way more tips, check out onceupon/Bash-Oneliner
- Julia Evans - A list of new(ish) command line tools
- [curl converter(https://curlconverter.com/)
- Szymon Stepniak jq tutorials on YouTube. Part 1, Part 2 and Part 3