Sometimes, when working at the shell prompt, we can be constructing a long command and then realise we’re not ready to run the command just yet.
We could hit the Home key, type a hash (
#) to comment the line, and hit return. That would put the command in the history without running it, and we can recall it later (up arrow) and edit it when we’re ready to run it.
There’s a shortcut for the above: just type
Let’s imagine we’ve started to build a command line like this:
Then we realise we need to move some files first. At the point we’re at above, we type
Alt-#. The display now looks like this:
Now we can do whatever we needed to do first, then recall this command, remove the hash and carry on.
Could This Linux Tip be Improved?
Let us know in the comments below.