Created
April 1, 2019 19:57
-
-
Save treyharris/edaaf77fd5c379444dff4080c6510061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*-shell-script-*- | |
# Get zshoptions manpage, advanced to definition of the option. This | |
# is made more interesting because underscores within option names are | |
# optional. So to be on the safe side, we stick "_?" between each | |
# character. | |
# | |
# The expansion ${(j:_?:)${(s//)1}} works like this, reading | |
# right-to-left: | |
# | |
# 1. We take the arg $1 | |
# 2. We split it into an array by characters (s//) | |
# 3. We take that and join each element with "_?" (j:_?:) | |
[[ $#@ -eq 1 ]] || { echo "Give one argument as a pattern" ; return 1} | |
name="$1" | |
PAT=${(j:_?:)${(s//)name}} | |
LESS="${LESS}+/^ +${PAT}" man zshoptions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment