From 73dcb99f28f22ea776c613deb7ee9b0b64d19854 Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 27 Jan 2020 21:05:40 +0800 Subject: update --- scripts/gist | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/gist b/scripts/gist index 34e4330..3cb53f5 100755 --- a/scripts/gist +++ b/scripts/gist @@ -45,10 +45,12 @@ # Since now a gist is a local cloned repo # It is your business to do git commit and git push # +# * configuration +# gist (config | c) [token ] [user ] [folder ] +# # * show this help message # gist (help | h) -# TODO add config to help message # TODO error handling, unit test # TODO parallel branch works with json parsing on python # TODO parallel branch works with wget and other stuff @@ -148,7 +150,7 @@ _parse_response() { _sync_repos() { local list_file=$index - [[ "$1" == "--star" ]] && list_file=$starred && route="gists/starred" + [[ "$1" =~ ^(star|s)$ ]] && list_file=$starred && route="gists/starred" # clone repos which are not in the local comm -13 <(find $folder -maxdepth 1 -type d | sed '1d; s#.*/##' | sort) \ @@ -179,13 +181,19 @@ _gist_id() { fi } -# FIXME error handling, if repo not cloned yet _goto_gist() { _gist_id $1 + + if [[ ! -d $folder/$GIST_ID ]]; then + echo 'Cloning gist as repo...' + git clone git@github.com:$GIST_ID.git $folder/$GIST_ID && \ + echo 'Repo is cloned' || \ + echo 'Failed to clone the gist' + fi + echo This gist is at $folder/$GIST_ID echo -e "You can run the following command to jump to this directory: \n" - echo -e " \e[32m. gist $1\e[0m" - echo + echo -e " \e[32m. gist $1\e[0m\n" cd $folder/$GIST_ID && ls && tig --all 2> /dev/null } -- cgit v1.2.3-70-g09d2