summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xscripts/gist22
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/gist b/scripts/gist
index bea6642..fe839a3 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -63,13 +63,27 @@ set -eo pipefail
63[ "$TRACE" ] && set -x 63[ "$TRACE" ] && set -x
64 64
65_auth() { 65_auth() {
66 echo 'Hi fellow! To access your gists, I need your Github username and a personal token with scope which allows "gist"!'
66 read -p "Github username: " user < /dev/tty 67 read -p "Github username: " user < /dev/tty
67 mkdir -p ~/.config && umask 0077 && echo user=$user > $config 68 if [[ $new_token =~ ^[[:alnum:]]+$ ]]; then
68 echo "Create a new token from web browser" 69 mkdir -p ~/.config
69 python -mwebbrowser https://github.com/settings/tokens/new\?scopes\=gist 70 umask 0077
71 echo user=$user > $config
72 else
73 echo "Not a valid username"
74 return 0
75 fi
76
77 echo -n "Create a new token from web browser? [Y/n] "
78 read answer < /dev/tty
79 if [[ ! $answer =~ ^(N|n|No|NO|no)$ ]]; then
80 python -mwebbrowser https://github.com/settings/tokens/new\?scopes\=gist;
81 fi
70 82
71 read -p "Paste your token here: " new_token < /dev/tty 83 read -p "Paste your token here: " new_token < /dev/tty
72 echo token=$new_token >> $config 84 [[ $new_token =~ ^[[:alnum:]]{40}$ ]] \
85 && echo token=$new_token >> $config \
86 || echo "Not a valid token"
73} 87}
74 88
75case "$1" in 89case "$1" in