A shortcut to edit long shell commands in your $EDITOR (#tilPost)

If you’re wrangling long shell commands, you know that tweaking parameters can be a bit of a pain. Especially when your command spans multiple lines and includes line breaks, you must be careful not to lose your changes. Press one k…


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

If you're wrangling long shell commands, you know that tweaking parameters can be a bit of a pain. Especially when your command spans multiple lines and includes line breaks, you must be careful not to lose your changes. Press one key too much, and you're shuffling through your shell history and your current changes will be gone.

But today I learned that there's hope. If you want to edit an already typed command in your favorite editor, you can press ctrl + x followed by ctrl + e.

This combination triggers the so-called edit-and-execute-command, which then creates a temporary file, opens it in the editor defined in your shell's $EDITOR variable, and when you save and close this file — your terminal command will be updated. Pretty magical!

Editing of a command using `ctrl + x` and `ctrl + e`

If VS Code is your daily driver, I tested the shortcut with EDITOR=code, but it didn't work on my machine.


Reply to Stefan


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis


Print Share Comment Cite Upload Translate Updates
APA

Stefan Judis | Sciencx (2024-09-07T22:00:00+00:00) A shortcut to edit long shell commands in your $EDITOR (#tilPost). Retrieved from https://www.scien.cx/2024/09/07/a-shortcut-to-edit-long-shell-commands-in-your-editor-tilpost/

MLA
" » A shortcut to edit long shell commands in your $EDITOR (#tilPost)." Stefan Judis | Sciencx - Saturday September 7, 2024, https://www.scien.cx/2024/09/07/a-shortcut-to-edit-long-shell-commands-in-your-editor-tilpost/
HARVARD
Stefan Judis | Sciencx Saturday September 7, 2024 » A shortcut to edit long shell commands in your $EDITOR (#tilPost)., viewed ,<https://www.scien.cx/2024/09/07/a-shortcut-to-edit-long-shell-commands-in-your-editor-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » A shortcut to edit long shell commands in your $EDITOR (#tilPost). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/07/a-shortcut-to-edit-long-shell-commands-in-your-editor-tilpost/
CHICAGO
" » A shortcut to edit long shell commands in your $EDITOR (#tilPost)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2024/09/07/a-shortcut-to-edit-long-shell-commands-in-your-editor-tilpost/
IEEE
" » A shortcut to edit long shell commands in your $EDITOR (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2024/09/07/a-shortcut-to-edit-long-shell-commands-in-your-editor-tilpost/. [Accessed: ]
rf:citation
» A shortcut to edit long shell commands in your $EDITOR (#tilPost) | Stefan Judis | Sciencx | https://www.scien.cx/2024/09/07/a-shortcut-to-edit-long-shell-commands-in-your-editor-tilpost/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.