Nemo Tab Restore is a nemo-python extension that adds browser-like closed-tab restoration to the Nemo file manager.
Tabs closed with Ctrl+W, mouse actions, and similar close operations can be restored with Ctrl+Shift+Y.
- Saves history for tabs closed with
Ctrl+W - Saves history for tabs closed with mouse actions or the File menu
- Restores the most recently closed tab with
Ctrl+Shift+Y - Supports changing shortcuts
- Supports configuration through a configuration file or environment variables
- Supports shared, per-window, or hybrid restore history
- Supports file-backed or in-memory history
In addition to Nemo itself, this extension needs the Python bindings that let Nemo load Python extensions, plus the GI / PyGObject packages used by those bindings. Some distributions pull part of this stack through the Nemo package itself, so the number of extra packages may vary by environment.
On Linux Mint 22.3 Cinnamon, this extension has been confirmed to work without installing additional packages. In the tested default environment, python-nemo, gir1.2-nemo-3.0, python3-gi, and python3-gi-cairo were already available.
Try the install steps first. If Nemo does not load the extension after restarting, check the related packages:
dpkg -l python-nemo gir1.2-nemo-3.0 python3-gi python3-gi-cairoThe following package names are confirmed on Ubuntu 24.04-family systems:
sudo apt install nemo-python gir1.2-nemo-3.0 python3-gi python3-gi-cairoOn Ubuntu-family releases, package names may vary. If installation fails, check the available package names with apt search nemo-python and apt search gir1.2-nemo.
sudo zypper install python3-nemo typelib-1_0-Nemo-3_0On Tumbleweed, installing python3-nemo also installs the matching Python GObject packages.
sudo pacman -S nemo nemo-pythonOn Arch Linux, installing nemo also installs python-gobject and python-cairo.
Install this extension file into Nemo's Python extension directory.
To install manually:
mkdir -p ~/.local/share/nemo-python/extensions
cp nemo_tab_restore.py ~/.local/share/nemo-python/extensions/nemo_tab_restore.pyA helper script is also available to automate the commands above:
./scripts/install.shWhen run in an interactive terminal, the script asks whether to restart Nemo after installation. Use --restart to restart without prompting, or --no-restart to skip both the prompt and restart. In a non-interactive environment, Nemo is not restarted unless --restart is specified.
./scripts/install.sh --restart
./scripts/install.sh --no-restartAfter installing, Nemo must be quit completely and started again. Newly installed extensions are not loaded until Nemo is restarted. If the script did not restart Nemo, run:
nemo -q
nemo &You can also start Nemo normally from the desktop launcher after quitting it with nemo -q.
If you cloned the repository with Git, fetch the latest version and run the install script again. The script does not modify configuration, history, or logs.
git pull --ff-only
./scripts/install.sh --restartIf you downloaded a release archive or source files, replace them with the new version and run ./scripts/install.sh again. See CHANGELOG.md for version-specific changes and upgrade notes.
Starting with v0.7.0, the default restore shortcut changed from Ctrl+Shift+T to Ctrl+Shift+Y. This avoids overriding Nemo's built-in Open in New Tab shortcut.
Explicit shortcut settings in the environment, configuration file, or accelerator file take precedence over the new default. To adopt Ctrl+Shift+Y, unset the environment variable and remove or comment out an existing Ctrl+Shift+T override in the configuration or accelerator file. See Shortcuts for accelerator file candidates.
Remove the installed extension file.
To remove it manually:
rm ~/.local/share/nemo-python/extensions/nemo_tab_restore.pyA helper script is also available to automate the command above:
./scripts/uninstall.shAs with the install script, you can pass --restart or --no-restart. When run without an option in an interactive terminal, the script asks whether to restart Nemo after removal.
The uninstall script removes only the installed extension file. History and logs are kept.
The extension saves the closed tab URI to history for these close operations:
Ctrl+W- tab close button
- middle-click on a tab
- tab context menu close
- File menu Close
The URI is saved after Nemo confirms that the tab was actually closed.
Ctrl+Shift+Y
The extension pops the most recently closed URI from history and restores the tab.
Internally, it opens the tab in the existing Nemo window with:
nemo --existing-window --tabs URINemo's menu also includes Restore Last Closed Tab.
Extension install path:
~/.local/share/nemo-python/extensions/nemo_tab_restore.py
History file:
~/.local/share/nemo-tab-restore/closed-tabs.jsonl
This file is not used when the history mode is memory.
Log file:
~/.cache/nemo-tab-restore/nemo-tab-restore.log
Configuration file:
~/.config/nemo-tab-restore/config.env
History, log, and configuration directories are created for owner-only access. Their files are also readable and writable only by the owner.
Configuration is done with environment variables or a configuration file. Environment variables are useful for temporary overrides. For persistent settings, use the configuration file so the values do not depend on how Nemo was started.
Settings listed higher take precedence. For example, if the configuration file and an environment variable specify different values, the environment variable value is used.
environment variables
configuration file
Nemo / GTK accelerator file (shortcuts only)
defaults
Environment variables are useful when starting Nemo from a terminal to try temporary settings.
Sets this extension's restore shortcut.
NEMO_TAB_RESTORE_RESTORE_SHORTCUT=Ctrl+Shift+YThe default is Ctrl+Shift+Y. To use the browser convention, specify a different shortcut such as Ctrl+Shift+T.
Nemo itself uses Ctrl+Shift+T for Open in New Tab. If you assign the same shortcut, the built-in action may be hidden. See the Shortcuts section below for details.
Sets the maximum number of closed-tab history entries to keep.
NEMO_TAB_RESTORE_MAX_HISTORY=100The default is 100, and the maximum is 1000.
Sets where closed-tab history is stored.
NEMO_TAB_RESTORE_HISTORY_MODE=file
NEMO_TAB_RESTORE_HISTORY_MODE=memoryThe default is file. Closed-tab history is saved to ~/.local/share/nemo-tab-restore/closed-tabs.jsonl.
When set to memory, history is kept only in memory while Nemo is running. It is lost when Nemo quits completely, and the history file is not read or written.
Sets how restore history is handled across Nemo windows.
NEMO_TAB_RESTORE_HISTORY_SCOPE=shared
NEMO_TAB_RESTORE_HISTORY_SCOPE=window
NEMO_TAB_RESTORE_HISTORY_SCOPE=hybridThe default is shared.
shared uses one restore history across all Nemo windows.
window restores only tabs closed in the current window.
hybrid prefers the current window's history. If there is nothing to restore for the current window, history from closed windows and old-format history entries is also considered.
Configures debug logging.
NEMO_TAB_RESTORE_LOG=true
NEMO_TAB_RESTORE_LOG=falseUse true or false in normal use. Logging is disabled by default when the variable is not set.
When starting Nemo from a terminal, place environment variables before the command to apply temporary settings:
NEMO_TAB_RESTORE_LOG=true nemoYou can also set multiple environment variables at once:
NEMO_TAB_RESTORE_LOG=true NEMO_TAB_RESTORE_MAX_HISTORY=300 nemoThe configuration file uses the same names and values as the environment variables above, written as KEY=value.
If the configuration file does not exist, the extension creates it the first time it is loaded. All settings are created as commented-out examples. Uncomment only the settings you want to override.
~/.config/nemo-tab-restore/config.env
When new settings are added in a newer version, existing configuration files are not updated automatically. To regenerate the latest sample, save any settings you still need, delete ~/.config/nemo-tab-restore/config.env, and restart Nemo.
Example:
NEMO_TAB_RESTORE_MAX_HISTORY=300
NEMO_TAB_RESTORE_HISTORY_MODE=memory
NEMO_TAB_RESTORE_HISTORY_SCOPE=hybrid
NEMO_TAB_RESTORE_LOG=true
NEMO_TAB_RESTORE_RESTORE_SHORTCUT=Ctrl+Shift+YThe configuration file uses a .env-like format. It is not a full shell script.
Supported format:
KEY=value
# comment
blank lines
export, variable expansion, and complex shell quoting or escaping are not supported.
No shortcut configuration is required by default. Ctrl+W saves closed-tab history, and Ctrl+Shift+Y restores the most recently closed tab.
Nemo assigns Ctrl+Shift+T to <Actions>/DirViewActions/OpenInNewTab, which opens selected items in new tabs. To avoid overriding that built-in action, this extension uses Ctrl+Shift+Y by default.
If you prefer the browser convention, you can assign Ctrl+Shift+T through an environment variable or the configuration file. Nemo's built-in Open in New Tab action will then no longer be available through the same shortcut. See NEMO_TAB_RESTORE_RESTORE_SHORTCUT for details.
To also change Nemo's built-in shortcuts, such as Open in New Tab, you need to edit Nemo / GTK's accelerator file.
If the accelerator file does not exist, you can create this path manually. See Behavior details for other candidate paths.
~/.config/nemo/accels/nemo
Quit Nemo before editing the accelerator file. If Nemo is still running, it may overwrite your changes when it exits.
nemo -qIn GTK accelerator notation, <Primary> usually means the Ctrl key.
Example: change tab restore to Ctrl+Shift+T through the accelerator file:
(gtk_accel_path "<Actions>/NemoTabRestore/RestoreLastClosedTab" "<Primary><Shift>t")The close shortcut follows Nemo's existing close action (<Actions>/ShellActions/Close). Normally, you do not need to change it.
Syntax check:
/usr/bin/python3 -m py_compile nemo_tab_restore.pyUnit tests:
/usr/bin/python3 -m unittest discover -s tests -vStart Nemo with logging enabled:
nemo -q
sleep 1
rm -f ~/.cache/nemo-tab-restore/nemo-tab-restore.log
NEMO_TAB_RESTORE_LOG=true nemo &Inspect the log:
tail -f ~/.cache/nemo-tab-restore/nemo-tab-restore.logExpected window hook:
hooked window wid=0x... title='Loading...'
mapped tab page=... uri=file:///...
- This extension restores closed tabs individually when requested. It does not manage Nemo sessions or restore the tabs that were open when Nemo last exited.
- Tracking tab closes from mouse actions can depend on the Nemo version, theme, and GTK widget structure. If it does not work in a given environment, keyboard shortcut closes are still tracked.
- When closing an inactive tab with a mouse action or opening its context menu, the extension may briefly switch to that tab to capture its URI. It switches back to the previously active tab after capturing the URI.
- This is a Nemo extension, not a Nautilus or Caja extension.
Nemo Python extensions use GI / PyGObject.
Nemo loads Python extensions with the distribution Python environment. If another Python installation is first in PATH, gi may fail to import even though it works with the distribution Python.
Check:
which -a python3
python3 --version
python3 -c 'import gi; print(gi.__file__)'Expected example:
/usr/bin/python3
/usr/lib/python3/dist-packages/gi/__init__.py
When debugging GI import problems, check the distribution Python directly:
/usr/bin/python3 -c 'import gi; print(gi.__file__)'- The close shortcut marks the current tab as a close candidate. Its URI is saved only after Nemo's normal close action actually removes the tab.
- The restore shortcut pops a URI from history and opens it in the existing Nemo window.
- Each key press is handled separately, matching browser-like behavior.
- Consecutive duplicate URIs are not suppressed. The same folder can legitimately be open in multiple tabs.
- URIs are tracked per notebook page, so the closed page is identified correctly across multiple windows and F3 split panes.
- When closing an inactive tab with a mouse action before its URI is known, the extension briefly switches to that tab to capture the URI, then returns to the previously active tab after the close.
- With
NEMO_TAB_RESTORE_HISTORY_SCOPE=shared, closed-tab history is shared rather than tracked per window. - When
NEMO_TAB_RESTORE_HISTORY_SCOPE=windowis combined withNEMO_TAB_RESTORE_HISTORY_MODE=file, history from old windows remains in the history file but is not restored from the current window. If needed, switch tosharedorhybridto make those entries eligible for restore. - With
NEMO_TAB_RESTORE_HISTORY_SCOPE=hybrid, history from other currently open Nemo windows is not used as fallback restore history.
The accelerator file location can vary by distribution and Nemo / GTK version. The extension checks these candidates:
$XDG_CONFIG_HOME/nemo/accels/nemo
$XDG_CONFIG_HOME/gtk-3.0/accels/nemo
~/.config/nemo/accels/nemo
~/.gnome2/accels/nemo
~/.config/gtk-3.0/accels/nemo
$XDG_CONFIG_HOME paths are checked first when the variable is set and non-empty.
MIT License. See LICENSE.