Nicolas Fabre

Terminal utilities

Sometime I find out some new command, or terminal program that scratch an itch in my daily workflow.

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.

### reverse-i-search

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.

fzf

fzf is a general-purpose command-line fuzzy finder, that you can plug in any list you wish. You can define a bash function to call it on your history to recall convoluted commands the easy way:

1h() {
2  history | fzf
3}
4

aliases

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

Which should give you some ideas about which commands to create aliases for.

K8s

Start a pod and run an interactive shell in it, using Alpine Linux. Handy to debug from inside your cluster. The pod is deleted when you drop off.

1alias kdebug="kubectl run -i --tty --rm debug --image=alpine --restart=Never -- sh"
2