Prab's Code Blog

Because talk is cheap, show me the code!

Find Below

This is a small piece of snippet that can go into your .zshrc and make your life easier sometimes. This whips up a new command named findbelow for you. This command takes as argument, a string and returns all the files below your current directory whose names contain the entered string as a substring.

findbelow
1
2
3
findbelow () {
  find ./ -regex ".*/$1.*"
}

Bonus

The below piece of snippet enables you to jump n directories upwards from your current pwd by typing u n. For example: u 5 will take you 5 directories up from your current position.

u
1
2
3
4
5
u () {
  set -A ud
  ud[1+${1-1}]=
  cd ${(j:../:)ud}
}

This has been tested on zsh.

Comments