aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xscripts/gist17
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/gist b/scripts/gist
index 2fc5624..de9ec6f 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -48,6 +48,7 @@
48# * show this help message 48# * show this help message
49# gist (help | h) 49# gist (help | h)
50 50
51# TODO pipe syntax fix
51# TODO error handling, unit test 52# TODO error handling, unit test
52# TODO parallel branch works with json parsing on python 53# TODO parallel branch works with json parsing on python
53# TODO parallel branch works with wget and other stuff 54# TODO parallel branch works with wget and other stuff
@@ -82,12 +83,14 @@ done
82 83
83github_api=https://api.github.com 84github_api=https://api.github.com
84auth_header="Authorization: token $github_api_token" 85auth_header="Authorization: token $github_api_token"
85[[ -z $folder ]] && folder=~/git/gist 86
87[[ -z "$folder" ]] && folder=~/git/gist
86mkdir -p $folder 88mkdir -p $folder
87index=$folder/index 89index=$folder/index
88starred=$folder/starred 90starred=$folder/starred
89 91
90# Show the list of gist, but not updated time 92# Show the list of gist, but not updated time
93# TODO a way to show files
91# TODO show git status outdated 94# TODO show git status outdated
92_show_list() { 95_show_list() {
93 if [[ ! -e "$1" ]]; then 96 if [[ ! -e "$1" ]]; then
@@ -274,14 +277,14 @@ _help_message() {
274 277
275# TODO consider the case that $2 is empty -> remove original setting 278# TODO consider the case that $2 is empty -> remove original setting
276_configure() { 279_configure() {
277 [[ -z "$@" ]] && vim $config && exit 0 &> /dev/null 280 [[ -z "$@" ]] && vim $config && exit 0 &> /dev/null ||\
281 echo edit file $config directly && exit 0
282
278 case "$1 $2" in 283 case "$1 $2" in
279 token[[:space:]]????????????????????????????????????????) 284 token) echo github_api_token=$2 ;;
280 echo $1=$2 ;;
281 auto_sync[[:space:]]true) echo $1=$2 ;;
282 auto_sync[[:space:]]false) echo $1=$2 ;; 285 auto_sync[[:space:]]false) echo $1=$2 ;;
283 folder[[:space:]]*) echo $1=$2 ;; 286 folder[[:space:]]*) echo $1=$2 ;;
284 *) echo Not well formated && exit 0;; 287 *) echo Not well formated; exit 0;;
285 esac >> $config 288 esac >> $config
286 sed -i "$ q; /^$1=/ d" $config 289 sed -i "$ q; /^$1=/ d" $config
287 290
@@ -290,7 +293,7 @@ _configure() {
290 293
291case "$1" in 294case "$1" in
292 "") 295 "")
293 _show_list $index ;; 296 show_list $index ;;
294 star | s) 297 star | s)
295 _show_list $starred ;; 298 _show_list $starred ;;
296 update | u) 299 update | u)