Linux alternate of open command in Mac/Windows

i have been to mac world once when i was into iphone development (which was fun) and there i came across the “open” command which can be executed on terminal and mac opens the file in the right application for you, great, isn’t it? I came back to linux world and was missing that but never had much time to check around. The other day i found some time so here are my findings (from google, stackoverflow and etc), my conclusions:

There are two commands available on my laptop. One is xdg-open and other is gnome-open,. The former is available on any system running X while latter is only available on GNOME Desktop (and may be only opens stuff on gnome applications, not sure about this though as i didn’t chose this, read on). So i chose xdg-open but its pretty long command to type when you wanna open just one file, and i am lazy (sysadmin/bum). So here is what i do:

I make alias to it like

alias open=xdg-open

Its still pretty long to type so i make it more short like

alias ]=open

there, now its great. To handle more than one files i make a small script only containing a function:

# /home/shoaibi/.open
for i in $*
xdg-open "$i"

give myself +x permissions and now change my open alias to:

alias open=/home/shoaibi/.open

phew, it was a long day :P, but totally worth it, now i can open pdf files, jpg files, odt, even urls, tell me about it.

I am back after a long break due to health issues, thanks for all the prayers and wishes :D

Tags: , , , , , , , , , , ,


  1. Hisham says:

    Nice thing…. And simple Script :)

  2. nob says:

    Cool. They should make this behaviour to a standard.

  3. Stepanna says:

    yo. bookmarked :)

Leave a Comment