iTerm2: Is it possible to open the current line in a text editor?

Viewed 1105

When writing long commands, it is quite time consuming to use the arrow keys to edit the line.

Is there any method where I can use a keyboard shortcut to open everything on the current line (that has not yet been executed) in a fast text editor (sublime), edit the line, and then save/close and have the edits written back out to the terminal ready to be executed?

2 Answers

iTerm2 has a really nice feature for this use case: the composer. It opens a native text field, where you can type more easily than in the command-line interface.

You can open it from the menu (View > Composer), or using the shortcut ā‡§āŒ˜..

iTerm2 with the composer open

If you're using bash, then pressing Ctrl+X Ctrl+E will open the current line in your default text editor. (It uses the $EDITOR environment variable to determine which editor to use iirc)

Related