I use the terminal a lot. Using terminal commands is often the fastest or easiest way to do something on a computer, and running vastly different tasks doesn’t require openning many different applications. One of the tools that I use the most often is ffmpeg, a great tool for anything video, audio or image related. It’s really a great tool that only requires running a command in the terminal. Despite its incredible power, it has a great flaw: it requires very long commands.
This is a recurring problem in the terminal: commands become very long and difficult to edit. Paths often take up a large amount of characters and it all becomes a large mess. In addition to this, the terminal line has terrible editing tools. You can’t select text or use shift. Many buttons on the keyboard are also processed in a bizarre way. On the other hand, a great way to edit text is with nvim. It’s incredibly efficient once you get good at it. My idea was therefor just to be able to quickly toggle into a nvim interface with nvim shortcuts when editing long commands but stay entirely within the terminal. The point would be to be able to quickly toggle between the line of commands and the vim mode to edit long commands efficiently?
It turns out it’s really easy! I’m not the first person to have thought of this. The shortcut ctrl-x ctrl-e opens the command in the terminal defined in .zshrc. This means that I simply need to add export EDITOR=nvim and I can now edit my commands in nvim.
One last thing: the ctrl-x ctrl-e shortcut isn’t memorable or easy to use so I can remap it to escape by adding the following line to .zshrc:
bindkey '\e' edit-command-line
This works very well! I can now edit long commands very easily. This is just another example of how easy it is to personalize computers. This only took a few minutes to set up and will vastly improve my workflow when working on long commands. It also begs the question of how many low hanging fruits there are. How many cases are there where vast improvements are a few minutes of work away from being much better?