Skip to content

Commit

Permalink
🆕 invoke gist-paste when gist unavailable
Browse files Browse the repository at this point in the history
The gist package installed via apt
under Ubuntu 20.04
uses gist-paste as the exectuable instead of gist.

Thus gister will invoke gist-paste instead if gist is not found in PATH.
  • Loading branch information
weakish committed Jul 31, 2022
1 parent a5e5a34 commit e06d1ba
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bin/gister
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ else
DATE=date
fi

# Ubuntu compatibility
if type gist > /dev/null; then
GIST=gist
else
GIST=gist-paste
fi

help() {
cat<<'END'
gister -- shell script to access https://gist.github.com
Expand Down Expand Up @@ -340,7 +347,7 @@ publish() {
else
gist_argv=$@
# post gist and open it in browser
gist -c -d "$gist_description" $gist_argv
$GIST -c -d "$gist_description" $gist_argv
# record the id
local gist_id=$(get_paste | grep -o -E '/[0-9a-f]+$' | $SED -e 's/\///')
# add a record
Expand Down Expand Up @@ -392,7 +399,7 @@ init() {
if ! test -f $HOME/.gist; then
echo 'We need your username and password to get an OAuth2 token (with the "gist" permission).'
echo 'We will not store your password.'
gist --login
$GIST --login
echo 'Your GitHub OAuth2 token is stored at ~/.gist'
fi
# store
Expand Down

0 comments on commit e06d1ba

Please sign in to comment.