diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gist | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/scripts/gist b/scripts/gist index c454fc7..fe38e38 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -15,13 +15,9 @@ | |||
15 | # | 15 | # |
16 | # * list your gists with format: [number] [url] [file_num] [comment_num] [short description] | 16 | # * list your gists with format: [number] [url] [file_num] [comment_num] [short description] |
17 | # gist [star | s] | 17 | # gist [star | s] |
18 | # | ||
19 | # * clone gist repos which are not in local | ||
20 | # * pull master branch if a local repo is behind its remote | ||
21 | # gist (sync | S) | ||
22 | # | 18 | # |
23 | # * Go to local gist repo | 19 | # * show the path of local gist repo and files |
24 | # . gist <number_of_gist_in_list> | 20 | # gist <index_of_gist> |
25 | # | 21 | # |
26 | # * create a new gist with files | 22 | # * create a new gist with files |
27 | # gist (new | n) [-d | --desc "<gist-description>"] <files>... | 23 | # gist (new | n) [-d | --desc "<gist-description>"] <files>... |
@@ -30,13 +26,13 @@ | |||
30 | # gist (new | n) [-d | --desc "<gist-description>"] [-f | --file <file>] < <file-with-content> | 26 | # gist (new | n) [-d | --desc "<gist-description>"] [-f | --file <file>] < <file-with-content> |
31 | # | 27 | # |
32 | # * show the detail of a gist | 28 | # * show the detail of a gist |
33 | # gist (detail | d) <gist_index> | 29 | # gist (detail | d) <index_of_gist> |
34 | # | 30 | # |
35 | # * edit a gist description | 31 | # * edit a gist description |
36 | # gist (edit | e) <gist_index> | 32 | # gist (edit | e) <index_of_gist> |
37 | # | 33 | # |
38 | # * delete a gist | 34 | # * delete a gist |
39 | # gist (delete | D) <gist_index>... | 35 | # gist (delete | D) <index_of_gist>... |
40 | # | 36 | # |
41 | # * clean removed gists in local | 37 | # * clean removed gists in local |
42 | # gist (clean | C) | 38 | # gist (clean | C) |
@@ -59,7 +55,7 @@ | |||
59 | # TODO test on mac and remote machine | 55 | # TODO test on mac and remote machine |
60 | # TODO completion | 56 | # TODO completion |
61 | 57 | ||
62 | # Validate configuration | 58 | # Shell configuration |
63 | set -eo pipefail | 59 | set -eo pipefail |
64 | [ "$TRACE" ] && set -x | 60 | [ "$TRACE" ] && set -x |
65 | 61 | ||
@@ -291,8 +287,6 @@ _gist_id() { | |||
291 | fi | 287 | fi |
292 | } | 288 | } |
293 | 289 | ||
294 | # FIXME source cause eixt | ||
295 | # TODO a better way without source | ||
296 | _goto_gist() { | 290 | _goto_gist() { |
297 | _gist_id $1 | 291 | _gist_id $1 |
298 | 292 | ||
@@ -300,17 +294,15 @@ _goto_gist() { | |||
300 | echo 'Cloning gist as repo...' | 294 | echo 'Cloning gist as repo...' |
301 | git clone git@github.com:$GIST_ID.git $folder/$GIST_ID | 295 | git clone git@github.com:$GIST_ID.git $folder/$GIST_ID |
302 | if [[ "$?" -ne 0 ]]; then | 296 | if [[ "$?" -ne 0 ]]; then |
303 | echo 'Repo is cloned' | 297 | echo 'Repo is cloned' > /dev/tty |
304 | else | 298 | else |
305 | echo 'Failed to clone the gist' | 299 | echo 'Failed to clone the gist' > /dev/tty |
306 | fi | 300 | fi |
307 | fi | 301 | fi |
308 | 302 | ||
309 | echo This gist is at $folder/$GIST_ID | 303 | echo $folder/$GIST_ID |
310 | echo -e "You can run the following command to jump to this directory: \n" | 304 | cd $folder/$GIST_ID && ls |
311 | echo -e " \e[32m. gist $1\e[0m\n" | 305 | #tig --all 2> /dev/null || true |
312 | echo -n 'files: ' && cd $folder/$GIST_ID && ls | ||
313 | tig --all 2> /dev/null || true | ||
314 | } | 306 | } |
315 | 307 | ||
316 | _delete_gist() { | 308 | _delete_gist() { |