How to open terminal output with a texteditor without the creation of a new file?
Many programs conventionally use -
to mean standard input or standard output. Thus, you can open the screen output of a command in nano using -
as the file name, as in:
ls | nano -
This will only work if your program does support that convention. This includes nano
and vi
on the terminal. Even the graphical text editor gedit
supports it. However, pluma
or mousepad
do not support it, and instead will be instructed to create a regular file named -
. In other cases, you cannot get around creating a regular intermediate file first.
If viewing with tilde is really needed, you may script your idea
Create a function in your .bashrc
function tildeIt () {
tmpfile=$(mktemp)
"$@" > $tmpfile
tilde $tmpfile
rm $tmpfile
}
# $@ is all words typed after tildeIt
# mktemp creates a temp file and returns his fullname
Reload .bashrc
source ~/.bashrc
Usage
tildeIt command -option
If you have vipe
, you can do
ls | vipe >/dev/null
The program vipe
(which I believe stands for either vi pipe or view pipe) reads standard in, opens $EDITOR
on it, and writes whatever is left when you save-and-quit to standard out.