DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Linux : Open, Copy And Paste, Mouse Or Keyboard? Who Cares - With This.

08.14.2006
| 5311 views |
  • submit to reddit
        From http://news.u32.net/articles/2006/07/31/shell-vs-file-manager:

Would you rather click on files or type at them? This is the root of a dichotomy that has existed ever since day one (day one was some time in mid 1964 according to my sources). Except for TwoDudes' short-lived FinderShell, I have never seen a program that effectively combines the strengths of each environment. Why must we choose?

Here's a stupid trick that makes it easier to move data from mouse mode to finger mode and back. Add the following to ~/.bashrc or equivalent:
alias open=gnome-open
alias copy="xclip -i"
alias paste="xclip -o"
Now open opens pretty much anything:
open mswd.doc
    opens mswd.doc in OpenOffice or AbiWord (whatever your default is).
open tt.mov
    opens the QuickTime clip in a movie player.
open .
    opens a new Nautilus window showing the current directory.
open http://u32.net
    opens a new browser window showing this blog.

And copy and paste manipulate the clipboard:

    * paste (with no arguments) prints the clipboard to the terminal.
    * Select some text in a text editor and then run paste > newfile to save that selection to a file.
    * copy bigfile copies the contents of bigfile into the clipboard.
    * copy *.log copies the contents of all log files in the current directory.

Of course, you can combine these tricks:
paste | tr a-z A-Z | copy
    converts the contents of the clipboard to upper-case.
paste | tr A-Za-z N-ZA-Mn-za-m | copy
    will rot13 the clipboard. 

More in blog post...