Pontus Öwre

Dedicated and diverse software engineer with 15+ years professional experience. Passionate about software security, test driven development and DevOps with interest in getting things done.

Custom context items in Nemo, Cinnamon

Posted

Nemo is the official file manager of the Cinnamon desktop environments and it allows for a lot of customization. One of the features that I find very useful is the ability to add custom context menu items. This can be useful when you want to quickly open a file or folder in your favorite editor or terminal. One use case for myself is to add an item to open files and folders in Visual Studio Code.

To add custom context items (right click menu) in Nemo you need to create an .nemo_action definition file in the ~/.local/share/nemo/actions directory. .nemo_action files are simple text files you use to define custom actions (context items).

Lets add a custom context item to open folder and files in Visual Studio Code - “Open In VS Code”.

Add the following content to the file ~/.local/share/nemo/actions/open_in_vs_code.nemo_action:

[Nemo Action]
Name=Open In VS Code
Exec=code %F
Icon-Name=com.visualstudio.code
Selection=any
Extensions=any;
Dependencies=code;

The Exec field specifies the command to run when the context item is clicked. %F is a placeholder for the selected files or folders. The Icon-Name field specifies the icon to use for the context item. The Selection field specifies the type of selection the context item should be displayed for. The Extensions field specifies the file extensions the context item should be displayed for with any meaning “any file type, including directories”. The Dependencies field specifies the dependencies required for the context item to be displayed.

See more examples and the complete definition of .nemo_action files here

Happy customizing!