Last active
April 10, 2018 04:48
-
-
Save alexklapheke/6525f71570b21ad21c2a9385dec2e3b6 to your computer and use it in GitHub Desktop.
Template for nautilus/nemo scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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