til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Edit Complex CLI in Editor

When you are writing or editing a particularly long command line in the shell, you can enter the following key combination and spawn of an editor to assist your.

<ctrl>-x-e

When closing the editor the command line entered is executed.

You can specify what editor to use using two different variables.

$ env | grep -e 'EDITOR\|VISUAL'
EDITOR=/usr/local/bin/vim
VISUAL=code --wait --new-window

The shell should pick the appropriate one.

An alternative to <ctrl>-x-e is fc it takes the last command from your history. Do note that is does not respect $VISUAL and uses $EDITOR.

Resources and References