zsh-users / zsh-syntax-highlighting

Fish shell like syntax highlighting for Zsh.
github.com/zsh-users/zsh-syntax-highlighting
BSD 3-Clause "New" or "Revised" License
20.29k stars 1.33k forks source link

highlighters/regexp/README.md uses an unportable example #746

Open jnooree opened 4 years ago

jnooree commented 4 years ago

In macOS, the word boundary syntax "\b" is not supported.

I think it's a good idea to add comment for macOS users, to use "[[:<:]]" and "[[:>:]]" rather than "\b".

Thank you for reading.

danielshahaf commented 4 years ago

The stackoverflow question you referenced is entitled Does bash support word boundary regular expressions? and z-sy-h does not support bash. What does () { typeset -pm ZSH\*; for 1; [[ $1 =~ '\bfoo' ]] && echo $1 } foo barfoo output on your system?

jnooree commented 4 years ago

Hello, thanks for responding. This is the output.

typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
typeset -g ZSH_THEME_GIT_PROMPT_CLEAN=$'%{\C-[[34m%})'
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
typeset -g ZSH_HIGHLIGHT_VERSION=0.7.2-dev
typeset -g ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
typeset -g -a ZSH_AUTOSUGGEST_CLEAR_WIDGETS=( history-search-forward history-search-backward history-beginning-search-forward history-beginning-search-backward history-substring-search-up history-substring-search-down up-line-or-beginning-search down-line-or-beginning-search up-line-or-history down-line-or-history accept-line copy-earlier-word )
typeset -g ZSH_VERSION=5.7.1
typeset -g ZSH_PATCHLEVEL=zsh-5.7.1-0-g8b89d0d
typeset -g -A ZSH_HIGHLIGHT_PATTERNS=( )
typeset -g -a ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=( forward-char end-of-line vi-forward-char vi-end-of-line vi-add-eol )
typeset -g ZSH_THEME_RVM_PROMPT_OPTIONS='i v g'
typeset -g -a ZSH_HIGHLIGHT_HIGHLIGHTERS=( main brackets regexp root )
typeset -g ZSH_THEME_TERM_TITLE_IDLE=%n@%m
typeset -g ZSH_THEME=robbyrussell_jnr
typeset -g -a ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=( forward-word emacs-forward-word vi-forward-word vi-forward-word-end vi-forward-blank-word vi-forward-blank-word-end vi-find-next-char vi-find-next-char-skip )
typeset -g -A ZSH_HIGHLIGHT_STYLES=( [arg0]='fg=green' [assign]=none [autodirectory]='fg=green,underline' [back-dollar-quoted-argument]='fg=cyan' [back-double-quoted-argument]='fg=cyan' [back-quoted-argument]=none [back-quoted-argument-delimiter]='fg=magenta' [bracket-error]='fg=red,bold' [bracket-level-1]='fg=blue,bold' [bracket-level-2]='fg=green,bold' [bracket-level-3]='fg=magenta,bold' [bracket-level-4]='fg=yellow,bold' [bracket-level-5]='fg=cyan,bold' [command-substitution]=none [command-substitution-delimiter]='fg=magenta' [commandseparator]=none [comment]='fg=black,bold' [cursor]=standout [cursor-matchingbracket]=standout [default]=none [dollar-double-quoted-argument]='fg=cyan' [dollar-quoted-argument]='fg=yellow' [double-hyphen-option]=none [double-quoted-argument]='fg=yellow' [global-alias]='fg=cyan' [globbing]='fg=blue' [history-expansion]='fg=blue' [line]='' [named-fd]=none [numeric-fd]=none [path]=underline [path_pathseparator]='' [path_prefix_pathseparator]='' [precommand]='fg=green,underline' [process-substitution]=none [process-substitution-delimiter]='fg=magenta' [rc-quote]='fg=cyan' [redirection]='fg=yellow' [reserved-word]='fg=yellow' [root]=standout [single-hyphen-option]=none [single-quoted-argument]='fg=yellow' [suffix-alias]='fg=green,underline' [unknown-token]='fg=red,bold' )
typeset -g ZSH_HIGHLIGHT_REVISION=HEAD
typeset -g ZSH_THEME_GIT_PROMPT_DIRTY=$'%{\C-[[34m%}) %{\C-[[33m%}✗'
typeset -g ZSH_THEME_TERM_TAB_TITLE_IDLE='%15<..<%~%<<'
typeset -g -A ZSH_HIGHLIGHT_REGEXP=( ['[[:<:]]sudo[[:>:]]']=bold,underline )
typeset -g -a ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=(  )
typeset -g ZSH_THEME_GIT_PROMPT_SUFFIX=$'%{\C-[[00m%}'
typeset -g ZSH_THEME_GIT_PROMPT_PREFIX=$' %{\C-[[01;34m%}git:(%{\C-[[31m%}'
typeset -g -a ZSH_HIGHLIGHT_DIRS_BLACKLIST=(  )
typeset -g ZSH_COMPDUMP=/Users/jnooree/.zcompdump-JNR-MBP-5.7.1
typeset -g ZSH_ARGZERO=-zsh
typeset -g ZSH_CUSTOM=/Users/jnooree/.oh-my-zsh/custom
typeset -g ZSH_NAME=zsh
typeset -g ZSH_THEME_RUBY_PROMPT_SUFFIX=')'
typeset -g -a ZSH_AUTOSUGGEST_IGNORE_WIDGETS=( 'orig-*' beep run-help set-local-history which-command yank yank-pop 'zle-*' )
typeset -g ZSH_CACHE_DIR=/Users/jnooree/.oh-my-zsh/cache
export ZSH=/Users/jnooree/.oh-my-zsh
typeset -g -a ZSH_AUTOSUGGEST_STRATEGY=( history )
typeset -g ZSH_THEME_RUBY_PROMPT_PREFIX='('
danielshahaf commented 4 years ago

Hello, thanks for responding. This is the output.

Thanks. On my system (Debian stable) it does print foo. Could you try it again with «setopt rcmatchpcre» in effect? You can leave the typeset command out this time.

jnooree commented 4 years ago

Well, when I type setopt rcmatchpcre, my terminal says setopt: no such option: rcmatchpcre. On the other hand, if you've meant setopt rematchpcre, the result is

update_terminal_cwd:12: failed to load module `zsh/pcre': dlopen(/usr/lib/zsh/5.7.1/zsh/pcre.so, 9): image not found
update_terminal_cwd:12: -pcre-match not available for regex
danielshahaf commented 4 years ago

Yes, I did. Sorry for the typo.

Would you like to prepare a pull request for this? I'm thinking it'll be much easier to change the example to one that works everywhere than to start explaining differences among regexp flavours, but TIMTOWTDI.

Well, when I type setopt rcmatchpcre, my terminal says setopt: no such option: rcmatchpcre. On the other hand, if you meant setopt rematchpcre, the result is

update_terminal_cwd:12: failed to load module `zsh/pcre': dlopen(/usr/lib/zsh/5.7.1/zsh/pcre.so, 9): image not found
update_terminal_cwd:12: -pcre-match not available for regex
jnooree commented 4 years ago

I created one: #747. Please review it, thanks.