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!

  • @Dehydrated
    link
    1711 months ago

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

    It’s easier to type in that way

    • @[email protected]OP
      link
      fedilink
      English
      811 months ago

      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
        link
        211 months ago

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

    • palordrolap
      link
      fedilink
      611 months ago

      Some systems already have this implemented. For example, on my machine open is /usr/bin/open which links to /etc/alternatives/open which in turn currently points at /usr/bin/xdg-open.

      • @Dehydrated
        link
        311 months ago

        I’ve seen this on a few Linux distros. MacOS also has something similar, not based on XDG but it works really well. It also uses the open command.