I sometimes want to make small edits to small file from within the shell I’m working in, while looking at my command history.
As an example, if I want to write a short shell script after experimenting on the command line, I can do:
cat > example.sh
and work from what I can see.
But cat’s not the best editor. If I use vi or emacs though (as far as I can tell) the whole environment changes, and I can only see what I’ve been doing is if I run the shell history command from inside the editor, which isn’t really what I want either.
I realise this is really nit-picky, but does anyone have any suggestions for a sensible editor (or way of using a sensible editor) that I can quickly invoke from the command-line and doesn’t spawn its own environment?
If you need to edit the command line, have a look at the (built-in)
fceditor (Bourne Shells).If you need to edit files though, nothing beats a real editor. You can use The Standard (
ed, man!) or what everybody else should be using,vi🙂Unlike
vi,eddoes not clear the screen; in fact, it is a line oriented editor. Note that some versions ofviin some terminals (vimin anxterm) can be configured to save the screen and restore it upon exit as it was before editing.