Nautilus actions, right click execute script

From WickyWiki
Revision as of 09:33, 28 September 2018 by Wilbert (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Add 'Scripts' option to Nautilus. After adding this script you can right-click, go to 'Scripts' and then 'exec'.

You can then disable the Nautilus script-dialog for executable files and pick your text editor as the default application. This dialog is especially annoying for NTFS drives where every text file is considered executable.

Configure

Create the 'Scripts' directory, sub-folders are also possible and will appear as sub-menu-items:

mkdir -p ~/.local/share/nautilus/scripts/

Create the script file, the filename is what will be used in the right-click menu. The script will run in a separate terminal window. It will also work for multiple scripts, one at the time, after each other:

gedit ~/.local/share/nautilus/scripts/exec
	#!/bin/bash
	while read -r fn; do
	  if [ -n "${fn}" ]; then
	    gnome-terminal -e "${fn}"	    
	  fi
	done <<< "${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}"

Make the script-file executable:

chmod +x ~/.local/share/nautilus/scripts/exec

See also