Remix.run Logo
hikarudo 8 hours ago

One trick I use all the time:

You're typing a long command, then before running it you remember you have to do some stuff first. Instead of Ctrl-C to cancel it, you push it to history in a disabled form.

Prepend the line with # to comment it, run the commented line so it gets added to history, do whatever it is you remembered, then up arrow to retrieve the first command.

$ long_command

<Home, #>

$ #long_command

<Enter>

$ stuff_1 $ stuff_2

<Up arrow a few times>

$ #long_command

<home, del>

$ long_command

gvalkov 6 hours ago | parent | next [-]

In zsh you can bind "push-line-or-edit". In bash and all readline programs, you can approximate it with C-u followed by C-y (i.e. cut and paste). My history is still full of '#' and ':' (csh trauma) prefixed command-lines like you described though ...

fragmede 8 hours ago | parent | prev [-]

Fwiw, in Bash, alt-shift-3 will prepend the current command with # and start a new command.

j4cobgarby 7 hours ago | parent [-]

More generally, it's alt-#. On an ISO (e.g. UK) keyboard layout, shift-3 isn't a hash.