From c2f03d72396b98a242e28fe42a55bd1c247363ed Mon Sep 17 00:00:00 2001 From: typebrook Date: Fri, 17 Jan 2020 01:04:54 +0800 Subject: update --- scripts/gist | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 5301df3..f9a1df6 100755 --- a/scripts/gist +++ b/scripts/gist @@ -64,11 +64,11 @@ _show_list() { while read line_num link file_url_array file_num extra description; do repo=$folder/$(echo $link | sed 's#.*/##') # if repo is not yet cloned, show green message "syncing" - cd $repo 2>/dev/null || extra="\e[32m[syncing]\e[0m" + cd $repo 2>/dev/null || extra="\e[32m[Sync Now]\e[0m" # if there is something need to commit, show blue message "working" - [[ -n $(git status --short) ]] && extra="\e[36m[working]\e[0m" 2>/dev/null + [[ -n $(git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" # if there is commit need to push, show red message "head" - [[ -n $(git cherry) ]] && extra="\e[31m[ahead]\e[0m" 2>/dev/null + [[ -n $(git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" echo -e $line_num $link $file_num $extra $description done @@ -114,17 +114,14 @@ _gist_id() { _goto_gist() { gist_num=$(wc -l $index | cut -d' ' -f1) - if [[ ! "$1" =~ [0-9]+ ]] || (( $1 > $gist_num )); then - echo Not a valid gist number: $1 - echo Use the number in the first column instead: - echo - _show_list + if [[ ! "$1" =~ ^[0-9]+$ ]] || (( $1 > $gist_num )); then + _show_list | grep "$1" || echo Nothing Found return 0 fi GIST_ID=$(_gist_id $1) echo This gist is at $folder/$GIST_ID - cd $folder/$GIST_ID && tig --all 2> /dev/null + cd $folder/$GIST_ID && ls && tig --all 2> /dev/null } _delete_gist() { -- cgit v1.2.3-70-g09d2