Nicolas Fabre

Lives and works in Helsinki, building software.


Terminal magic

May 15, 2020

Computers are awesome ! And the more you work with them, the more magic you can learn. It’s really like learning to cast spells. Sometime you find out some new command, or some new library that does something you didn’t even think was possible and you get blown away at how is that even possible.

Some of these are collected here for reference:

z - jump around

After installing and using cd to move around your directories like you usually do, z builds for you a small database of your most accessed directories and their path. Once that’s done - and I mean this is done everything you use cd - you can then use z instead of cd and only type a part of the path to magically jump there, even in nested directories. For example, if you have the following file structure:

  ├── work
  │   └── project1
  │   └── project2
  └── perso
      └── project3

you can then just type z 3 to go to ~/perso/project3. And it works really well.


This can be seen as a gadget but considering the pain it is to retype a command, or copy paste its correct suggestion from the output - why not install this and forget about it until you need it:

❯ nide
zsh: command not found: nide
# here you can either type in `fuck` or press esc. key two times
❯ node # appears by magic 🧙‍♂️


Just press ctrl+R in your terminal and get yourself some full text search of your command history. Very useful for recurrent commands that you don’t want to alias because they are contextual.


You can check your most used commands by using: history|awk '{print $2, $3}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -n

This should give you some ideas about the most frequently used commands that you could alias to something. I actually mostly alias git commands in my .gitconfig but you can also add aliases to your bash for more convenience

Discuss on Twitter