Let's say that I want the output of ls
viewed in nano
or tilde
.
I would do the following:
ls >> tmp
nano tmp
rm tmp
I don't like this because it creates a dumpfile that I sometimes forget to delete. Some people suggest this:
ls | less
or
ls | more
But I cannot do:
ls | nano
So how to solve this? I would need this especially when it comes to huge terminal outputs like the current processes where I would like to do a search afterwards.
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:This will only work if your program does support that convention. This includes
nano
andvi
on the terminal. Even the graphical text editorgedit
supports it. However,pluma
ormousepad
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
Reload
.bashrc
Usage
If you have
vipe
, you can doThe 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.On *nix, everything is a file. Thus, you can read the standard input from a file. In theory that is. Some programs get a bit iffy.
Depending on the editor, you can read /dev/stdin. For example,
cat
works, but gedit complains that /dev/stdin is a special file and can't be edited.What works with this method and what doesn't seem to be easily distinguished. So just try it with what you want, and it will either work, or not.
If you're using
bash
, you might trytilde <( ls )
.See Process Substitution in
bash(1)
.