Skip to content

Instantly share code, notes, and snippets.

@brccabral
Last active March 16, 2023 18:20
Show Gist options
  • Save brccabral/0d4b9f6e4d8132e4cb5fa6a3308e0076 to your computer and use it in GitHub Desktop.
Save brccabral/0d4b9f6e4d8132e4cb5fa6a3308e0076 to your computer and use it in GitHub Desktop.
Nemo actions

Nemo actions

Nemo is a free and open-source software and official file manager of the Cinnamon desktop environment. It is a fork of GNOME Files (formerly named Nautilus).

Nautilus is default in GNOME desktop, but although I use Ubuntu, which has GNOME as default, I don't like Nautilus.

Nemo has some features that works best for me, thus I decided to install Nemo on my Ubuntu GNOME.

  • Copy current path from the top bar
  • Right click option to open current folder as root (good to copy files to protected locations)
  • Create custom actions. This is the focus for this gist.

Install Nemo

sudo apt install nemo

Make Nemo default file manager

xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search

Hide GNOME desktop icons

gsettings set org.gnome.desktop.background show-desktop-icons false

Show Nemo desktop icons

It is marked as deprecated

gsettings set org.nemo.desktop show-desktop-icons true

Add Nemo-desktop to your autostart

Grab the file below, nemo-desktop.desktop, and copy it to your autostart folder ~/.config/autostart/nemo-desktop.desktop, or execute this to create and save the file

mkdir ~/.config/autostart
touch ~/.config/autostart/nemo-desktop.desktop
cat <<EOF > ~/.config/autostart/nemo-desktop.desktop
[Desktop Entry]
Type=Application
Exec=nemo-desktop
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=nemo-desktop
Name=nemo-desktop
Comment[en_US]=Nemo Desktop icons
Comment=Nemo Desktop icons
EOF

To go back to nautilus

xdg-mime default nautilus.desktop inode/directory application/x-gnome-saved-search
rm ~/.config/autostart/nemo-desktop.desktop
gsettings set org.gnome.desktop.background show-desktop-icons true
gsettings set org.nemo.desktop show-desktop-icons false
sudo apt purge nemo nemo*
sudo apt autoremove

Nemo Actions

This is a great feature. We can create a configuration file that adds your own commands to the Nemo context menu, the list that opens when you right click in Nemo.
We can setup actions for when you click on a blank space in the folder, when we click on a file, and we can filter specifc extensions or formats, if we have more than X number of files selected. More options in the Nemo documentation.
Currently I am using actions only for blank spaces in a folder.

  • git init %F - Initiates a git repository in current folder without command line or other tools
  • code %F - Open current folder in VSCode
  • git-cola cola -r %F - Open current folder in Git-Cola, an application for Git GUI
  • python3 -m venv %F/.venv - Create a Python virtual environment in current folder

Copy *.nemo_action files to actions folder

The Nemo actions folder is located at ~/.local/share/nemo/actions. Just copy files below to this location or execute these commands

Git init

cat <<EOF > ~/.local/share/nemo/actions/git_init.nemo_action
[Nemo Action]

Active=true
Name=Git Init
Comment=Initiate a Git Repository
Exec=git init %F
Selection=none
Extensions=dir;
Icon-Name=git-cola
Dependencies=git;
EOF

Open Git-Cola

cat <<EOF > ~/.local/share/nemo/actions/open_git-cola.nemo_action
[Nemo Action]

Active=true
Name=Open Git-Cola
Comment=Open Git-Cola in this folder
Exec=git-cola cola -r %F
Selection=none
Extensions=dir;
Icon-Name=git-cola
Dependencies=git-cola;
EOF

Open VSCode

cat <<EOF > ~/.local/share/nemo/actions/open_vscode.nemo_action
[Nemo Action]

Active=true
Name=Open VSCode
Comment=Open VSCode in this folder
Exec=code %F
Selection=none
Extensions=dir;
Icon-Name=com.visualstudio.code
Dependencies=code;
EOF

Open VSCodium

cat <<EOF > ~/.local/share/nemo/actions/open_vscodium.nemo_action
[Nemo Action]

Active=true
Name=Open VSCodium
Comment=Open VSCodium in this folder
Exec=codium "%F"
Selection=none
Extensions=dir;
Icon-Name=/usr/share/codium/resources/app/resources/linux/code.png
Dependencies=codium;
EOF

Create Python venv

cat <<EOF > ~/.local/share/nemo/actions/create_py_venv.nemo_action
[Nemo Action]

Active=true
Name=Create Python .venv
Comment=Create a Python virtual enviroment in this folder
Exec=python3 -m venv %F/.venv
Selection=none
Extensions=dir;
Icon-Name=python3
Dependencies=python3;
EOF
[Nemo Action]
Active=true
Name=Create Python .venv
Comment=Create a Python virtual environment in this folder
Exec=python3 -m venv "%F/.venv"
Selection=none
Extensions=dir;
Icon-Name=python3
Dependencies=python3;
[Nemo Action]
Active=true
Name=Git Init
Comment=Initiate a Git Repository
Exec=git init "%F"
Selection=none
Extensions=dir;
Icon-Name=git-cola
Dependencies=git;
[Desktop Entry]
Type=Application
Exec=nemo-desktop
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=nemo-desktop
Name=nemo-desktop
Comment[en_US]=Nemo Desktop icons
Comment=Nemo Desktop icons
[Nemo Action]
Active=true
Name=Open Git-Cola
Comment=Open Git-Cola in this folder
Exec=/bin/bash -c 'QT_QPA_PLATFORMTHEME=qt5ct git-cola cola -r "%F"'
Selection=none
Extensions=dir;
Icon-Name=git-cola
Dependencies=git-cola;
[Nemo Action]
Active=true
Name=Open VSCode
Comment=Open VSCode in this folder
Exec=code "%F"
Selection=none
Extensions=dir;
Icon-Name=com.visualstudio.code
Dependencies=code;
[Nemo Action]
Active=true
Name=Open VSCodium
Comment=Open VSCodium in this folder
Exec=codium "%F"
Selection=none
Extensions=dir;
Icon-Name=/usr/share/codium/resources/app/resources/linux/code.png
Dependencies=codium;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment