Navigating between directories efficiently
Dec 22, 2020
Working on the command line efficiently means to jump between directories as fast as possible.
Along with using plugins such as autojump, pushd and popd etc, I also use some custom aliases that I have created over time which help me be more efficient.
One such alias that I use is
cd.. nwhere n represents the number of directory levels you want to move up
The script is very crisp and elegant
function cd_up() {
cd $(printf "%0.s../" $(seq 1 $1 ));
}
alias 'cd..'='cd_up'
script credits : grigory-k
Add this function to ~/.bashrc
to be able to use the alias anywhere.
Usage:
Let us assume my current working directory is ~/interleap/Desktop/work/projects/userclient
~/interleap/Desktop/work/projects/userclient$ cd.. 2
~/interleap/Desktop/work$ cd.. 3
~
Script breakdown
e.g.
cd $(printf "%0.s../" $(seq 1 3 ));produces:
cd ../../../Output
Jumps up 3 directories
Hope you enjoyed it :)