aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xscripts/gist18
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/gist b/scripts/gist
index 34e4330..3cb53f5 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -45,10 +45,12 @@
45# Since now a gist is a local cloned repo 45# Since now a gist is a local cloned repo
46# It is your business to do git commit and git push 46# It is your business to do git commit and git push
47# 47#
48# * configuration
49# gist (config | c) [token <value>] [user <value>] [folder <value>]
50#
48# * show this help message 51# * show this help message
49# gist (help | h) 52# gist (help | h)
50 53
51# TODO add config to help message
52# TODO error handling, unit test 54# TODO error handling, unit test
53# TODO parallel branch works with json parsing on python 55# TODO parallel branch works with json parsing on python
54# TODO parallel branch works with wget and other stuff 56# TODO parallel branch works with wget and other stuff
@@ -148,7 +150,7 @@ _parse_response() {
148 150
149_sync_repos() { 151_sync_repos() {
150 local list_file=$index 152 local list_file=$index
151 [[ "$1" == "--star" ]] && list_file=$starred && route="gists/starred" 153 [[ "$1" =~ ^(star|s)$ ]] && list_file=$starred && route="gists/starred"
152 154
153 # clone repos which are not in the local 155 # clone repos which are not in the local
154 comm -13 <(find $folder -maxdepth 1 -type d | sed '1d; s#.*/##' | sort) \ 156 comm -13 <(find $folder -maxdepth 1 -type d | sed '1d; s#.*/##' | sort) \
@@ -179,13 +181,19 @@ _gist_id() {
179 fi 181 fi
180} 182}
181 183
182# FIXME error handling, if repo not cloned yet
183_goto_gist() { 184_goto_gist() {
184 _gist_id $1 185 _gist_id $1
186
187 if [[ ! -d $folder/$GIST_ID ]]; then
188 echo 'Cloning gist as repo...'
189 git clone git@github.com:$GIST_ID.git $folder/$GIST_ID && \
190 echo 'Repo is cloned' || \
191 echo 'Failed to clone the gist'
192 fi
193
185 echo This gist is at $folder/$GIST_ID 194 echo This gist is at $folder/$GIST_ID
186 echo -e "You can run the following command to jump to this directory: \n" 195 echo -e "You can run the following command to jump to this directory: \n"
187 echo -e " \e[32m. gist $1\e[0m" 196 echo -e " \e[32m. gist $1\e[0m\n"
188 echo
189 cd $folder/$GIST_ID && ls && tig --all 2> /dev/null 197 cd $folder/$GIST_ID && ls && tig --all 2> /dev/null
190} 198}
191 199