Skip to content

Instantly share code, notes, and snippets.

@matheusfaustino
Created September 11, 2018 19:16
Show Gist options
  • Save matheusfaustino/b5a0f677bd535c214df66c76fe04096a to your computer and use it in GitHub Desktop.
Save matheusfaustino/b5a0f677bd535c214df66c76fe04096a to your computer and use it in GitHub Desktop.
Nautilus script that uploads a file to transfer.sh and returns a link to share the file w/ notification (used to share images)
#!/bin/sh
trim() {
local var="$*"
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
echo -n "$var"
}
IFS='
'
for file in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
cmd=$(curl --upload-file $file https://transfer.sh/)
cmd=$(trim ${cmd})
echo "$cmd" | xclip -sel clip
notify-send -t 1000 -c info "Link copied" "File: $(basename \"$cmd\")"
# echo ${cmd} >> ./line
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment