diff options
author | johannst <johannst@users.noreply.github.com> | 2024-02-15 23:29:57 +0000 |
---|---|---|
committer | johannst <johannst@users.noreply.github.com> | 2024-02-15 23:29:57 +0000 |
commit | bac8a5d2822835cf47175d1162030653fadd5c09 (patch) | |
tree | 28f312a114cf95ac799daac2a2caec4b8612d84d /tools/zsh.html | |
parent | bfc5ce4bc01e5eb28969eefcc01ecfefa2601fdf (diff) | |
download | notes-bac8a5d2822835cf47175d1162030653fadd5c09.tar.gz notes-bac8a5d2822835cf47175d1162030653fadd5c09.zip |
deploy: 4485708c972815bbb6df7f5a228683aa855d553d
Diffstat (limited to 'tools/zsh.html')
-rw-r--r-- | tools/zsh.html | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/tools/zsh.html b/tools/zsh.html index acdc32f..e6ec715 100644 --- a/tools/zsh.html +++ b/tools/zsh.html @@ -198,11 +198,11 @@ $RBUFFER # Edit buffer content right to cursor # create zle widget which adds text right of the cursor function add-text() { - RBUFFER="some text $RBUFFER" + RBUFFER="some text $RBUFFER" } zle -N add-text -bindkey "^p" add-text +bindkey "^p" add-text </code></pre> <h2 id="parameter"><a class="header" href="#parameter">Parameter</a></h2> <p>Default value:</p> @@ -336,10 +336,10 @@ option should be stored.</li> <pre><code class="language-zsh">#!/bin/zsh function test() { zparseopts -D -E -A opts f=flag o: -long: - echo "flag $flag" - echo "o $opts[-o]" - echo "long $opts[--long]" - echo "pos $1" + echo "flag $flag" + echo "o $opts[-o]" + echo "long $opts[--long]" + echo "pos $1" } test -f -o OPTION --long LONG_OPT POSITIONAL @@ -361,9 +361,9 @@ The match results can be accessed via the <code>$MATCH</code> variable and <pre><code class="language-zsh">INPUT='title foo : 1234' REGEX='^title (.+) : ([0-9]+)$' if [[ $INPUT =~ $REGEX ]]; then - echo "$MATCH" # title foo : 1234 - echo "$match[1]" # foo - echo "$match[2]" # 1234 + echo "$MATCH" # title foo : 1234 + echo "$match[1]" # foo + echo "$match[2]" # 1234 fi </code></pre> <h2 id="completion"><a class="header" href="#completion">Completion</a></h2> @@ -395,7 +395,7 @@ $words[CURRENT-1] # previous word (relative to cursor position) </code></pre> <ul> <li><code>MSG</code> simple string with header message</li> -<li><code>COMP</code> array of completions where each entry is <code>"opt:description"</code></li> +<li><code>COMP</code> array of completions where each entry is <code>"opt:description"</code></li> </ul> <pre><code class="language-zsh">function _foo() { local -a opts @@ -436,16 +436,16 @@ function _foo_color() { colors+=('green:green color') colors+=('red:red color') colors+=('blue:blue color') - _describe "color" colors + _describe "color" colors } function _foo() { _arguments \ - "-c[define color]:color:->s_color" \ - "-s[select sound]:sound:(low high)" \ - "-f[select file]:file:_files" \ - "-d[select dir]:dir:_files -/" \ - "-h[help]" + "-c[define color]:color:->s_color" \ + "-s[select sound]:sound:(low high)" \ + "-f[select file]:file:_files" \ + "-d[select dir]:dir:_files -/" \ + "-h[help]" case $state in s_color) _foo_color;; @@ -459,9 +459,9 @@ arguments such as</p> </code></pre> <pre><code class="language-zsh">function _foo() { _arguments \ - "1:opt 1:(a b c)" \ - ":opt next:(d e f)" \ - "*:opt all:(u v w)" + "1:opt 1:(a b c)" \ + ":opt next:(d e f)" \ + "*:opt all:(u v w)" } </code></pre> <p>Explanation:</p> |