Skip to content

Instantly share code, notes, and snippets.

@creikey
Created April 7, 2018 05:39
Show Gist options
  • Save creikey/29ec5cb74ae343b17691ee78b2303ad1 to your computer and use it in GitHub Desktop.
Save creikey/29ec5cb74ae343b17691ee78b2303ad1 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
@creikey
Copy link
Author

creikey commented Apr 7, 2018

gist-cpy-anim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment