I know I can use Up to iterate through previous commands. Running the last command simply involves Up + Enter. However, I was thinking of buying the Happy Hacking Keyboard as I spend a lot of time in vim
.
This keyboard has no arrow keys, and the only way I know how to get this kind of behaviour is by pressing Ctrl + R and beginning to repeat my previous command.
Is there an easy way to emulate Up + Enter in an UNIX terminal without the arrow keys?
Best Answer
With
csh
or any shell implementingcsh
-like history substitution (tcsh
,bash
,zsh
):Then Enter.
Or alternatively:
Then Enter.
Or Ctrl+P, Enter
Magic space
Also, note that
!!
and!-1
will not auto-expand for you, until you execute them (when it might be too late).If using
bash
, you can putbind Space:magic-space
into~/.bashrc
, then pressing Space after the command will auto-expand them inline, allowing you to inspect them before execution. This is particularly useful for history expansion from a command run a while ago, e.g.!echo
will pull the last command run starting withecho
. With magic space, you get to preview the command before it's run.That's the equivalent of doing
bindkey ' ' magic-space
intcsh
orzsh
.