Is it possible to preserve my open tabs between closing and opening of Nautilus file manager?
Preferably even across different logouts and restarts.
Is it possible to preserve my open tabs between closing and opening of Nautilus file manager?
Preferably even across different logouts and restarts.
(Very) limited command line options of nautilus
Unfortunately, nautilus does not offer command line options to read the opened directory of its windows, nor does it have any option to send an existing window to another directory. Since you cannot remember what you do not see, we are running out of options at first sight.
However
We do have
xdotool
, not to do whatnautilus
doesn't, but to at least fake the behaviour that you describe. We can do that in such a way that "you would believe it" if you didn't know how it is done.Although the solution below does not survive a restart, "remembering" (possibly tabbed) window and all opened directories is very well possible within one session. Since you mentioned to be interested in that as a "second choice", here it is.
How it works; the process
Although We cannot close a window and preserve its tabs and opened directories, we can make an existing window seemingly (and completely) disappear, with the help of
xdotool
.If we subsequently change the behaviour of the
nautilus
launcher in such a way that it first looks for possible unmapped windows to remap, before opening a new one, effectively we have exactly the same behaviour as ifnautilus
would remember the last used window(s).How to set up
Copy the script below into an empty file, save it as
remember.py
The script needs both
wmctrl
andxdotool
:Copy the
nautilus
launcher from/usr/share/applications
to~/.local/share/applications
for 15.04 and later:
for earlier Ubuntu versions:
open the local copy with gedit:
(in case of
15.04 +
)and look for the first line, starting with
Exec=
. Change it into:Save and close the file.
Create a keyboard shortcut with the same command: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
Now log out and back in
How to use
The use is very simple:
To open a window, do as usual: click on the nautilus launcher. Tab the window as you like:
To close a window definitively, close it by clicking on the window's "close" (x) box.
To preserve the window(s) + all its tabs:
press the shortcut key. The window(s) will vanish (seemingly close).
Next time when you click the launcher, the nautilus window(s) will appear exactly like the last time, even the window position(s) will be preserved.
That's it
Note
EDIT:
Nemo users
Nemo users can equally use the solution above, but:
In the head section of the script, change:
into:
In point 3, use:
In point 4, use:
Tested, proved to be working with nemo
I recommend using other file manager instead if that's okay with you since Nautilus doesn't have that feature.
Here's one alternative app that does the trick: SpaceFM
Here's how to install it.
It has rich features such as, of course, reopen last tabs.
To make it the default file manager:
xdg-mime default spacefm.desktop inode/directory
Try out these scripts to save and restore tabs of nautilus file manager. https://github.com/susurri/nautilus_save_tabs/
The easiest way to access folders is bookmarking. You wont keep your tabs open but you can at least see the folders you want quickly (and if you think about it, the bookmarks act as tabs).
Just open a folder on Nautilus, go to Bookmark menu and add a bookmark.