Skip to content

Instantly share code, notes, and snippets.

@alexklapheke
Last active April 10, 2018 04:48
Show Gist options
  • Save alexklapheke/6525f71570b21ad21c2a9385dec2e3b6 to your computer and use it in GitHub Desktop.
Save alexklapheke/6525f71570b21ad21c2a9385dec2e3b6 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