diff options
author | typebrook <typebrook@gmail.com> | 2020-03-28 00:23:40 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-03-29 13:59:13 +0800 |
commit | 10963dece0ddd9d45fa16f4b4a5a8421871ecd63 (patch) | |
tree | d6b429580fac77f80b6512d964fe1405dcd28158 | |
parent | 328cbc344025ce95d83f5f2f76698f911d381f6a (diff) |
Add parameter for index range
-rwxr-xr-x | gist | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -762,6 +762,15 @@ _gists_with_languages() { | |||
762 | hint=false mark=${INPUT:+.} display=language _show_list | grep --color=always -Ei "$pattern" | 762 | hint=false mark=${INPUT:+.} display=language _show_list | grep --color=always -Ei "$pattern" |
763 | } | 763 | } |
764 | 764 | ||
765 | _gists_with_range() { | ||
766 | [[ ! $@ =~ ^s*[0-9]*-s*[0-9]*$ ]] && echo 'Invalid range' && exit 1 | ||
767 | local mark='' && [[ $@ =~ s ]] && mark=s | ||
768 | |||
769 | local range=$(sed -Ee "s/s//g; s/^-/1-/; s/-$/-$(wc -l <$INDEX)/; s/-/\n/" <<< "$*") | ||
770 | INPUT=$(seq $range | sed -e "s/^/p*$mark/") | ||
771 | hint=false _show_list | ||
772 | } | ||
773 | |||
765 | _apply_config "$@" || exit 1 | 774 | _apply_config "$@" || exit 1 |
766 | getConfiguredClient || exit 1 | 775 | getConfiguredClient || exit 1 |
767 | if [[ $init ]]; then _fetch_gists; exit 0; fi | 776 | if [[ $init ]]; then _fetch_gists; exit 0; fi |
@@ -816,6 +825,8 @@ case "$1" in | |||
816 | lan | l) | 825 | lan | l) |
817 | shift | 826 | shift |
818 | _gists_with_languages "$@" ;; | 827 | _gists_with_languages "$@" ;; |
828 | *-*) | ||
829 | _gists_with_range "$@" ;; | ||
819 | version) | 830 | version) |
820 | echo "Version $currentVersion" ;; | 831 | echo "Version $currentVersion" ;; |
821 | update) | 832 | update) |