dimanche 22 mars 2015

Coming back to a command I have partially written


Often I find myself partway through writing a long command (or chain of commands) and realise I need to run another command before I can finish typing out this current one.


Examples


Sometimes, I...



  • Need to find the exact name of a network interface (wlp2s0b1 -- blargh);

  • Need to check the documentation of a command;

  • Need to start a daemon (with systemctl,service, etc) before I can communicate with it;

  • Need to sudo ls a directory if I'm performing a command with sudo and tab-completion isn't working because I don't have permission in the directory I'm operating in.


I guess the ideal solution for me would be a keyboard shortcut that pushes my current command to a stack and empties the line, and another command that pops the top command from that stack into the input line.


Kinda-sorta-solutions that I currently use:



  • Use my mouse to select the command in the terminal (if I even have a graphical terminal available) and copy it, pasting when ready (slow);

  • Press enter (hoping that the command just fails than deleting things) and use to get back up to it (dangerous);

  • Type it out again (time-consuming)


Any suggestions for how I could better accomplish this? I use zsh where I can, but a solution that works on bash as well would be appreciated.



Aucun commentaire:

Enregistrer un commentaire