diff options
| author | typebrook <typebrook@gmail.com> | 2020-01-28 09:57:12 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-01-28 09:57:12 +0800 |
| commit | 9aa7980cb97d6ec13b86d670386ac70c05e5358b (patch) | |
| tree | a210472c8df2cf9886800f543de22a792ba62550 | |
| parent | 4419b80f31edc92307a856219cdf3bf21e867d69 (diff) | |
update
| -rwxr-xr-x | scripts/gist | 22 |
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 | ||
| 75 | case "$1" in | 89 | case "$1" in |