Skip to content

Instantly share code, notes, and snippets.

@creikey
Created April 7, 2018 05:40
Show Gist options
  • Save creikey/59aae892ac96a6325cb5e6127e4f33b1 to your computer and use it in GitHub Desktop.
Save creikey/59aae892ac96a6325cb5e6127e4f33b1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# uses github.com/defunkt/gist
## run `gem install gist`
## make sure to run `gist --login` on install
# uses github.com/astrand/xclip
## run `sudo apt install xclip`
# this could be anything and it'll use zenity, nothing and it won't
use_zenity=""
if [ "$use_zenity" != "" ]; then
zenity --timeout 2 --question --text="Upload a gist?"
prompt_code="$?"
else
prompt_code="0"
fi
if [ "$prompt_code" == "0" ]; then
if [ "$(xclip -selection c -o)" != "" ]; then
url="$(xclip -selection c -o | gist)"
else
echo "Nothing in clipboard!"
exit
fi
echo "$url" | xclip -selection c
if [ "$use_zenity" != "" ]; then
zenity --timeout 1 --info --text="Gist uploaded to $url!"
fi
else
echo "Cancelling upload..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment