aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-28 00:23:40 +0800
committertypebrook <typebrook@gmail.com>2020-03-29 13:59:13 +0800
commit10963dece0ddd9d45fa16f4b4a5a8421871ecd63 (patch)
treed6b429580fac77f80b6512d964fe1405dcd28158
parent328cbc344025ce95d83f5f2f76698f911d381f6a (diff)
Add parameter for index range
-rwxr-xr-xgist11
1 files changed, 11 insertions, 0 deletions
diff --git a/gist b/gist
index c93bb13..cf09f6f 100755
--- a/gist
+++ b/gist
@@ -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
766getConfiguredClient || exit 1 775getConfiguredClient || exit 1
767if [[ $init ]]; then _fetch_gists; exit 0; fi 776if [[ $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)