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
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
- The
<>
syntax resolves paths relative to the location of the .nemo_action file - It preserves environment variables and context
- With
Terminal=true
, it automatically launches in a terminal without needing to explicitly call terminal emulators
[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;
- 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.
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