It should be possible to do that by having ALT+UP generate consecutive keyboard input equivalent to cdspace..ENTER by means of a macro definition. But can't figure out how exactly to do it.
To do literally what you're asking, put the following line in your
"\e\e[A": "cd ..\n"
\e\e[A is byte sequence that your terminal sends when you press Alt+Up (
\e is parsed as the escape character), some terminals might send
\e[1;3A~ or some other sequence instead. To find out what sequence your terminal sends, run
cat and press the key (escape will display as
In bash, you can in principle bind a key to shell code, so in theory this should work:
bind -x '"\e\e[A":cd ..'
However as of bash 4.2 it doesn't work due to a hard-to-fix implementation bug. Zsh expert Stéphane Chazelas has a workaround:
bind -x '"\201":cd ..' bind '"\e\e[A":"\201"'
The effect is somewhat confusing because the prompt isn't redrawn.
In bash ≥4, add
shopt -s autocd to your
~/.bashrc. Then you can change to the parent directory (or any directory) by entering just
.., without having to type the