I'm trying to bind Ctrl-minus to prevd in fish. The desired behaviour is that I press the keybinding and I go to the previous directory. I have tried this:
bind \c_ 'prevd'
The problem is that I have to press enter after pressing the keybinding for it to work. Also it displays the message 'Hit end of history…' when I hit the end of history. I would like to suppress this. Does anyone know how I could achieve this? Thanks
The problem is that I have to press enter after pressing the keybinding for it to work
You actually don't. The prevd
happens immediately, but the prompt isn't repainted, so it doesn't display the new directory.
So the binding needs to also do commandline -f repaint
.
Also it displays the message 'Hit end of history…' when I hit the end of history.
That message is printed by prevd
, on stdout (for some reason). To inhibit stdout, redirect it to /dev/null, like prevd >/dev/null
.
So, in conclusion:
bind \c_ 'prevd >/dev/null; commandline -f repaint'