Skip to content

Instantly share code, notes, and snippets.

@dkebler
Created March 9, 2025 17:19
Show Gist options
  • Save dkebler/d79d171792938139824390437f92a051 to your computer and use it in GitHub Desktop.
Save dkebler/d79d171792938139824390437f92a051 to your computer and use it in GitHub Desktop.
nemo action relative path to script with Exec

Nemo Actions with Relative Paths

The Problem

Nemo file manager actions (.nemo_action files) in Linux typically require absolute paths when specifying executables, which causes issues with:

  • Portability between systems
  • Moving application directories
  • Sharing configurations between users
  • Maintaining action files in version control

For example, this is the common approach that's problematic:

[Nemo Action]
Name=Clone Repository
Comment=Clone a Git repository
Exec=/home/username/projects/scripts/clone-git-repo.sh
Terminal=true

The Solution: Using <> Syntax

Nemo actions support a little-known feature: using angle brackets <> to reference scripts relative to the action file location.

[Nemo Action]
Name=Clone Repository
Comment=Clone a Git repository
Exec=<../scripts/clone-git-repo.sh>
Terminal=true

How It Works

  1. The <> syntax resolves paths relative to the location of the .nemo_action file
  2. It preserves environment variables and context
  3. With Terminal=true, it automatically launches in a terminal without needing to explicitly call terminal emulators

Complete Example

[Nemo Action]
Name=Clone Repository
Comment=Clone a Git repository
Exec=<../scripts/clone-git-repo.sh>
Terminal=true
Icon-Name=git
Selection=none
Extensions=any;

Benefits

  • Cleaner Code: No absolute paths hardcoded in the action file
  • Portability: Works across systems without modification
  • Maintainability: Scripts can move with the action file
  • Simplified Development: Easier to test and deploy

This approach works with the Nemo file manager commonly used in Linux Mint and other distributions.

Note

This same technique might also apply to .desktop files (untested), and potentially other file manager action implementations like Nautilus (GNOME Files) scripts, but this has been specifically tested with Nemo actions.


Shared by: dkeblergood
Date: 2025-03-09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment