From 2a1cca0c60d20c2d6f6abd857e09a569c7ca07c3 Mon Sep 17 00:00:00 2001 From: typebrook Date: Wed, 25 Dec 2019 18:07:28 +0800 Subject: update --- scripts/gist | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 7dc06e2..284edd0 100755 --- a/scripts/gist +++ b/scripts/gist @@ -27,6 +27,15 @@ _sync_repos() { } _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 + cat $index + return 0 + fi + GIST_ID=$(cat $index | sed -n "$1"p | cut -d' ' -f2 | sed -r 's#.*/##') echo this gist is at $folder/$GIST_ID cd $folder/$GIST_ID && tig --all 2> /dev/null -- cgit v1.2.3-70-g09d2