diff options
-rwxr-xr-x | gist | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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 |
775 | getConfiguredClient || exit 1 | 785 | getConfiguredClient || exit 1 |
776 | if [[ $init ]]; then _fetch_gists; exit 0; fi | 786 | if [[ $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 "$@" ;; |
839 | esac | 851 | esac |