aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xgist14
1 files changed, 12 insertions, 2 deletions
diff --git a/gist b/gist
index 5c393d5..0c7a5af 100755
--- a/gist
+++ b/gist
@@ -466,6 +466,15 @@ _gist_id() {
466 fi 466 fi
467} 467}
468 468
469# set gist id either by given index or current directory
470_set_gist_id() {
471 if [[ -z $1 ]]; then
472 [[ $(dirname $(pwd)) == $folder ]] && GIST_ID=$(basename $(pwd)) || return 1
473 else
474 _gist_id "$1" || return 1
475 fi
476}
477
469# Show path of repo by gist ID, and perform action 478# Show path of repo by gist ID, and perform action
470_goto_gist() { 479_goto_gist() {
471 echo "$folder/$GIST_ID" 480 echo "$folder/$GIST_ID"
@@ -539,8 +548,9 @@ for comment in raw:
539# Show the detail of a gist 548# Show the detail of a gist
540# TODO add parameter --comment to fetch comments 549# TODO add parameter --comment to fetch comments
541_show_detail() { 550_show_detail() {
542 _gist_id "$1" || return 1 551 _set_gist_id $1 || return 1
543 sed -n "/^$1 / p" $INDEX \ 552
553 sed -En -e "/[^ ]+ [^ ]+$GIST_ID / p" $INDEX \
544 | while read -r "${INDEX_FORMAT[@]}"; do 554 | while read -r "${INDEX_FORMAT[@]}"; do
545 local hashtags=$(_hashtags "$description") 555 local hashtags=$(_hashtags "$description")
546 echo desc: ${description%% $hashtags} 556 echo desc: ${description%% $hashtags}