summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xscripts/gist25
1 files changed, 14 insertions, 11 deletions
diff --git a/scripts/gist b/scripts/gist
index 9654a49..2fc5624 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -52,11 +52,10 @@
52# TODO parallel branch works with json parsing on python 52# TODO parallel branch works with json parsing on python
53# TODO parallel branch works with wget and other stuff 53# TODO parallel branch works with wget and other stuff
54# TODO completion 54# TODO completion
55# define your environmemnts here 55
56#------------------- 56# Validate settings.
57folder=~/git/gist
58config=~/.config/gistrc 57config=~/.config/gistrc
59#------------------- 58[ "$TRACE" ] && set -x
60 59
61# TODO error handling while password is not true 60# TODO error handling while password is not true
62_auth() { 61_auth() {
@@ -83,13 +82,11 @@ done
83 82
84github_api=https://api.github.com 83github_api=https://api.github.com
85auth_header="Authorization: token $github_api_token" 84auth_header="Authorization: token $github_api_token"
85[[ -z $folder ]] && folder=~/git/gist
86mkdir -p $folder 86mkdir -p $folder
87index=$folder/index 87index=$folder/index
88starred=$folder/starred 88starred=$folder/starred
89 89
90# Validate settings.
91[ "$TRACE" ] && set -x
92
93# Show the list of gist, but not updated time 90# Show the list of gist, but not updated time
94# TODO show git status outdated 91# TODO show git status outdated
95_show_list() { 92_show_list() {
@@ -275,14 +272,20 @@ _help_message() {
275 sed -E -n ' /^$/ q; 8,$ s/^#//p' $0 272 sed -E -n ' /^$/ q; 8,$ s/^#//p' $0
276} 273}
277 274
275# TODO consider the case that $2 is empty -> remove original setting
278_configure() { 276_configure() {
277 [[ -z "$@" ]] && vim $config && exit 0 &> /dev/null
279 case "$1 $2" in 278 case "$1 $2" in
280 auto_sync[[:space:]]*) echo -n $1 ;;& 279 token[[:space:]]????????????????????????????????????????)
281 *true) echo =$2;; 280 echo $1=$2 ;;
282 *false) echo =$2;; 281 auto_sync[[:space:]]true) echo $1=$2 ;;
283 folder) echo -n $1=$2 ;; 282 auto_sync[[:space:]]false) echo $1=$2 ;;
283 folder[[:space:]]*) echo $1=$2 ;;
284 *) echo Not well formated && exit 0;;
284 esac >> $config 285 esac >> $config
285 sed -i "$ q; /^$1=/ d" $config 286 sed -i "$ q; /^$1=/ d" $config
287
288 cat $config
286} 289}
287 290
288case "$1" in 291case "$1" in