When I type nautilus .
, it will open the current directory in Nautilus only outside of the terminal, and I can go on with whatever I want to keep doing in the terminal, without having to cancel the process first.
Now, when i create an alias like
alias open="nautilus ."
and write "open" in the terminal, Nautilus will open as expected in the current directory, but it will also open in the terminal ("Initializing nautilus-dropbox 2019.02.14"), meaning I can't use the terminal until I cancel this process. Cancelling the process however will also close nautilus.
How can I prevent this?
Best Answer
tl;dr: Use
xdg-open .
instead ofnautilus .
(both manually and in aliases) to open Nautilus.The precise effect of running
nautilus
in the terminal depends on factors that include whether or notnautilus
is already running. When you start an instance ofnautilus
from the terminal and it detects an existing instance, it tells that instance what to do and quits; when it doesn't, it keeps running. You can usexdg-open
instead, which is usually the best way to open a file or directory in a graphical program, and which quits immediately whether or not an instance of the program was already running.To open a graphical file browser window for the current directory, you can use:
That command causes
.
(the current directory) to be opened by whatever program is configured to handle directories. The command itself immediately terminates. If your desktop environment uses Nautilus as its file browser, then the effect is to open it in Nautilus.If you're using a desktop environment that doesn't use Nautilus as its file browser--or if you've manually reconfigured what graphical program is responsible for opening directories--then typically you would want that other program to run instead, anyway. For example, Xubuntu uses Thunar as its file browser, and running
xdg-open .
in an Xubuntu session opens the current directory in Thunar, which is what you would probably want in that situation.The directory you open doesn't have to be
.
. For example,xdg-open ~/Downloads
opens your downloads folder.The
xdg-open
command can also be used to open things that are not directories. For example, if you have a LibreOffice Writer documentnotes.odt
, thenxdg-open notes.odt
will open that in LibreOffice Writer.In my experience, most of the time one considers running
nautilus some-directory
, what one wants is exactly the effect produced byxdg-open some-directory
.If you want a Bash alias for this--that is, specifically to open the current directory--you can still make one: