Nifty terminal command: xdg-open

Just sharing something neat I learned today about Linux…

In Windows, I used to do this a lot:
– Be at a command prompt, in some directory, e.g.: C:\my files\more files
– When I need to see that same folder in the Windows GUI, I’d type: start . (note the period, meaning “this directory”)
– The Windows file manager would open in a new window, focused on that same folder as the path.

I realized today I didn’t know how to do that in Linux (I’m on Ubuntu) so I searched around and found the xdg-open command.

The man page for xdg-open says:

xdg-open opens a file or URL in the user’s preferred application. If a URL is provided the URL will be opened in the user’s preferred web browser.

At any terminal prompt, I type something like:

xdg-open .

or xdg-open ~/Documents

And boom! A new KDE Dolphin files window appears, focused on that path.

or this works too, but with a browser:

xdg-open http://eff.org

Rock and/or roll!

library_napper,
@library_napper@monyet.cc avatar

I prefer thunar &

perishthethought,

Cool, from xfce, yeah. Why is it better?

library_napper,
@library_napper@monyet.cc avatar

When I type, it does what you expect (going to the file/folder in the current directory by what you type).

Some time ago the others started doing some annoying search thing when you type, and I can’t find how to turn that off. Anyway thunar is simper and gets the job done faster

Dehydrated,

I’d create an alias: alias open=xdg-open

It’s easier to type in that way

perishthethought,

I totally did, yes:

alias xo=‘xdg-open $1 &>/dev/null’

… since it always has some odd output when I run it here on my pc.

Dehydrated,

That’s actually a great idea, thanks for the suggestion

abuttandahalf,

xdg-open is one of the most used commands on my system. Video files, movies, pdfs, etc if I want to use the default application to open anything I use it. No need to memorize each application’ commands.

merthyr1831,

<3 XDG, bringing so much utility and cross-compatibility to Linux regardless of your distro and window manager

jbrains,

Between this and rifle, all things are possible. Enjoy.

offspec,

I believe this is simplified to open on most platforms

perishthethought,

Yep, that does for me too, thanks!!

Jumuta,

that’s cool

I’ve always just done


<span style="color:#323232;">dolphin .
</span>

but that’s nifty to know!

perishthethought,

Yes! That works too. Thanks!!

atzanteol,

xdg-open will check mime types and open files with preferred applications as well. So ‘xdg-open foo.ods’ will launch libre office for example.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #