Sometimes I want to redirect bash output directly into an X application for further editing. Normally this is done using a temporary file where the bash output is saved and then it is opened by an application. There's a way though to start an X application and paste the bash output into its window automatically.
To do this the xsel and xdotool programs should be installed:
1 2 | sudo apt-get install xsel xdotool |
1 2 | alias 2edit= 'xsel -b;n=pipe$RANDOM;xdotool exec --terminator -- mousepad $n -- search --sync --onlyvisible --name $n key --window %1 ctrl+v' |
Usage example:
1 2 | dpkg -l | 2edit |
It should be noted that a new window will be open only when the program that pipes into the 2edit has finished. This could be used as a notification to the user about finishing of a time consuming operation with its results pasted into the opened window.
No comments:
Post a Comment