Last Updated: February 25, 2016
·
255
· niedzielski

Make Bash Directory Navigation like Explorer

Add the following to your .bashrc to walk your directory stack like Windows Explorer. That is, change directories with alt + cursor keys.

# Map <Alt + CursorKey> bindings to unused keys, then map
# the unused keys to functions. (You can also use "cat -A" or
# "<Ctrl-V><Keys>" to dump the key sequences. There's no
# builtin termcap in infocmp / tput AFIK.)
bind '"\e[1;3A":"\201"' && bind -x '"\201":pushd ..' # Alt Up
bind '"\e[1;3C":"\203"' && bind -x '"\203":pushd -0' # Alt Rt
bind '"\e[1;3B":"\202"' && bind -x '"\202":popd'     # Alt Dn
bind '"\e[1;3D":"\204"' && bind -x '"\204":pushd +1' # Alt Lt