My current directory is buried deep in multiple subfolder layers from my home directory. If I want to open this directory in a gui-based file browser, I have to double click folder after folder to reach it. This is very time consuming. On the other hand, with very few key strokes and several times hitting the tab button, it is very easily reachable via a terminal.
I want to know if there is a way to open the current directory in a terminal onto a a file browser. What is the command to do this?
For reference, I have an ubuntu system, but I'd like to know what the commands are across the various distributions of linux.
Best Answer
xdg-open .
xdg-open is part of the xdg-utils package, which is commonly installed by default in many distributions (including Ubuntu). It is designed to work for multiple desktop environments, calling the default handler for the file type in your desktop environment.
You can pass a directory, file, or URL, and it will open the proper program for that parameter. For example, on my KDE system:
xdg-open .
opens the current directory in the Dolphin file managerxdg-open foo.txt
opens foo.txt in emacsclient, which I've configured to be the default handler for .txt filesxdg-open http://www.google.com/
opens google.com in my default web browserThe application opens as a separate window, and you'll get a prompt back in your terminal and can issue other commands or close your terminal without affecting your new GUI window.
I usually get a bunch of error message printed to
stderr
, but I just ignore them.Edit:
Adding the arguments
xdg-open . >/dev/null 2>&1
redirects the errors and the output. This call won't block your terminal. Binding this to an alias likefilemanager='xdg-open . >/dev/null 2>&1'
can come in handy.