aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-28 09:53:13 +0800
committertypebrook <typebrook@gmail.com>2020-03-29 13:59:13 +0800
commit69a0543263e793a94507d3cf40da73710eb04774 (patch)
treef8a9fdda080cba40b0374418e5574c392245a836
parentae4ab08dcd7de8969890b21834c34fe97dc06d00 (diff)
Add subcommand 'gist last'
-rwxr-xr-xgist18
1 files changed, 15 insertions, 3 deletions
diff --git a/gist b/gist
index b1bfda9..ef6a6ba 100755
--- a/gist
+++ b/gist
@@ -465,8 +465,7 @@ _gist_id() {
465} 465}
466 466
467# Return the path of local repo with a given index 467# Return the path of local repo with a given index
468# If action is not empty, eval it! 468_goto_gist_by_index() {
469_goto_gist() {
470 _gist_id "$1" || return 1 469 _gist_id "$1" || return 1
471 470
472 if [[ ! -d $folder/$GIST_ID ]]; then 471 if [[ ! -d $folder/$GIST_ID ]]; then
@@ -479,7 +478,13 @@ _goto_gist() {
479 fi 478 fi
480 fi 479 fi
481 480
481 _goto_gist
482}
483
484_goto_gist() {
482 echo "$folder/$GIST_ID" 485 echo "$folder/$GIST_ID"
486 touch "$folder/$GIST_ID"
487
483 if [[ -z $action ]]; then 488 if [[ -z $action ]]; then
484 action='echo Inside subshell, press \<CTRL-D\> to exit; ${SHELL:-bash}' 489 action='echo Inside subshell, press \<CTRL-D\> to exit; ${SHELL:-bash}'
485 fi 490 fi
@@ -771,6 +776,11 @@ _gists_with_range() {
771 hint=false _show_list 776 hint=false _show_list
772} 777}
773 778
779_access_last_index() {
780 GIST_ID=$(ls -tup $folder | grep / | head -1)
781 _goto_gist
782}
783
774_apply_config "$@" || exit 1 784_apply_config "$@" || exit 1
775getConfiguredClient || exit 1 785getConfiguredClient || exit 1
776if [[ $init ]]; then _fetch_gists; exit 0; fi 786if [[ $init ]]; then _fetch_gists; exit 0; fi
@@ -827,6 +837,8 @@ case "$1" in
827 _gists_with_languages "$@" ;; 837 _gists_with_languages "$@" ;;
828 *-*) 838 *-*)
829 _gists_with_range "$@" ;; 839 _gists_with_range "$@" ;;
840 last | L)
841 _access_last_index ;;
830 version) 842 version)
831 echo "Version $currentVersion" ;; 843 echo "Version $currentVersion" ;;
832 update) 844 update)
@@ -835,5 +847,5 @@ case "$1" in
835 help | h) 847 help | h)
836 usage ;; 848 usage ;;
837 *) 849 *)
838 _goto_gist "$@" ;; 850 _goto_gist_by_index "$@" ;;
839esac 851esac