diff options
| -rwxr-xr-x | gist | 34 |
1 files changed, 17 insertions, 17 deletions
| @@ -464,6 +464,20 @@ _gist_id() { | |||
| 464 | fi | 464 | fi |
| 465 | } | 465 | } |
| 466 | 466 | ||
| 467 | # Show path of repo by gist ID, and perform action | ||
| 468 | _goto_gist() { | ||
| 469 | echo "$folder/$GIST_ID" | ||
| 470 | touch "$folder/$GIST_ID" | ||
| 471 | |||
| 472 | if [[ $@ =~ --no-action ]]; then | ||
| 473 | return 0 | ||
| 474 | elif [[ -z $action ]]; then | ||
| 475 | action='echo Inside subshell, press \<CTRL-D\> to exit; ${SHELL:-bash}' | ||
| 476 | fi | ||
| 477 | |||
| 478 | cd "$folder/$GIST_ID" && eval "$action" | ||
| 479 | } | ||
| 480 | |||
| 467 | # Return the path of local repo with a given index | 481 | # Return the path of local repo with a given index |
| 468 | _goto_gist_by_index() { | 482 | _goto_gist_by_index() { |
| 469 | _gist_id "$1" || return 1 | 483 | _gist_id "$1" || return 1 |
| @@ -478,21 +492,7 @@ _goto_gist_by_index() { | |||
| 478 | fi | 492 | fi |
| 479 | fi | 493 | fi |
| 480 | 494 | ||
| 481 | _goto_gist | 495 | _goto_gist "$@" |
| 482 | } | ||
| 483 | |||
| 484 | _goto_gist() { | ||
| 485 | echo "$folder/$GIST_ID" | ||
| 486 | touch "$folder/$GIST_ID" | ||
| 487 | |||
| 488 | if [[ -z $action ]]; then | ||
| 489 | action='echo Inside subshell, press \<CTRL-D\> to exit; ${SHELL:-bash}' | ||
| 490 | fi | ||
| 491 | if [[ $2 == '--no-action' ]]; then | ||
| 492 | return 0 | ||
| 493 | else | ||
| 494 | cd "$folder/$GIST_ID" && eval "$action" | ||
| 495 | fi | ||
| 496 | } | 496 | } |
| 497 | 497 | ||
| 498 | # Delete gists with given indices | 498 | # Delete gists with given indices |
| @@ -778,7 +778,7 @@ _gists_with_range() { | |||
| 778 | 778 | ||
| 779 | _access_last_index() { | 779 | _access_last_index() { |
| 780 | GIST_ID=$(ls -tup $folder | grep / | head -1) | 780 | GIST_ID=$(ls -tup $folder | grep / | head -1) |
| 781 | _goto_gist | 781 | _goto_gist "$@" |
| 782 | } | 782 | } |
| 783 | 783 | ||
| 784 | _apply_config "$@" || exit 1 | 784 | _apply_config "$@" || exit 1 |
| @@ -838,7 +838,7 @@ case "$1" in | |||
| 838 | *-*) | 838 | *-*) |
| 839 | _gists_with_range "$@" ;; | 839 | _gists_with_range "$@" ;; |
| 840 | last | L) | 840 | last | L) |
| 841 | _access_last_index ;; | 841 | _access_last_index "$@" ;; |
| 842 | version) | 842 | version) |
| 843 | echo "Version $currentVersion" ;; | 843 | echo "Version $currentVersion" ;; |
| 844 | update) | 844 | update) |