Skip to content

Instantly share code, notes, and snippets.

@Hammer2900
Forked from alexklapheke/nemo_script_shell.sh
Created April 10, 2018 04:48
Show Gist options
  • Save Hammer2900/0e4b969edb5279bbd4cec19521ea4719 to your computer and use it in GitHub Desktop.
Save Hammer2900/0e4b969edb5279bbd4cec19521ea4719 to your computer and use it in GitHub Desktop.
Template for nautilus/nemo scripts
#!/bin/bash
# Template for Nemo scripts.
# Place in $HOME/.local/share/nemo/scripts/
# For Nautilus: s/NEMO/NAUTILUS/g
export IFS=$'\n'
curpath=${NEMO_SCRIPT_CURRENT_URI#file://}
files=$NEMO_SCRIPT_SELECTED_FILE_PATHS
cd "$curpath"
main () {
# magic
}
# For scripts that operate on each file individually:
if [ "$files" ]; then
for file in $files; do
main "$file"
done
else
for file in $curpath/*; do
main "$file"
done
fi
# For scripts that operate on files collectively:
if [ "$files" ]; then
main "$files";
else
main "$curpath/*"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment