My shell is GNU Bash 4.3.11, and I currently have M-h
bound to cd ..
by calling the builtin
bind -x '"\eh": "cd .."'
This gives me a nifty way to navigate up the directory tree, as I can repeatedly hit M-h
instead of the incredibly time-consuming cd ..
. It has the downside, however, either of not resetting my $PS1
or of not redrawing my prompt, so I lose the context of my current working directory until I enter a new command.
One alternative I'm aware of is to put a macro like
"\eh": "\C-a\C-kcd ..\C-m"
in my .inputrc
directly. This, however, has the downside of not only losing the context of any existing command I'm typing in (which I think can probably be worked around) but also of printing out cd ..
(which I don't think can be).
My desired behavior is to be able to be in a directory ~/one/two
with prompt ~/one/two$
; hit M-h
; and then be in ~/one
and have the prompt be ~/one$
, ideally keeping any command I had initially. How can I achieve this?