diff options
Diffstat (limited to 'Completion/Zsh/Type/_ps1234')
-rw-r--r-- | Completion/Zsh/Type/_ps1234 | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/Completion/Zsh/Type/_ps1234 b/Completion/Zsh/Type/_ps1234 new file mode 100644 index 000000000..8d3c5d861 --- /dev/null +++ b/Completion/Zsh/Type/_ps1234 @@ -0,0 +1,157 @@ +#compdef -value-,PROMPT,-default- -value-,PROMPT2,-default- -value-,PROMPT3,-default- -value-,PROMPT4,-default- -value-,RPROMPT,-default- -value-,RPROMPT2,-default- -value-,PS1,-default- -value-,PS2,-default- -value-,PS3,-default- -value-,PS4,-default- -value-,RPS1,-default- -value-,RPS2,-default- -value-,SPROMPT,-default- + +local -a specs +local expl bs suf pre changed=1 ret=1 + +if [[ -z $compstate[quote] ]]; then + bs='\' # in patterns we use (\\|) widely as print -P handles backslashes first +fi + +# first strip off any complete prompt specifications leaving only the +# current, incomplete, one +while (( changed )); do + changed=0 + compset -P '%[DFK](\\|){[^}]#}' && changed=1 # formats with arg: %x{...} + compset -P '%[0-9-\\]#[^DFK(0-9-<>\\\[]' && changed=1 # normal formats + compset -P '%[0-9-\\]#(<[^<]#<|>[^>]#>|\[[^\]]#\])' && changed=1 # truncations + compset -P '%[0-9-\\]#(\\|)\(??|[^%]' && changed=1 # start of ternary + compset -P '[^%]##' && changed=1 # sundry other characters + # %D/%F/%K without a following { ... } + [[ $PREFIX = %(-|)<->#[DFK](\\|)[^{\\]* ]] && + compset -P '%[0-9\\-]#[DFK]' && changed=1 +done +[[ $PREFIX = %(-|)<->[FK](#e) ]] && compset -P '*' # F/K with number + +if compset -P '%[FK]'; then + # this should use -P but that somehow causes single quotes to be stripped + compset -P '(\\|){' || pre=( -p "$bs{" ) + compset -S '(\\|)}*' || suf=( -S $bs\} ) + specs=( + black + red + green + yellow + blue + magenta + cyan + white + default + ) + _wanted ansi-colors expl 'ansi color' compadd $suf $pre -a specs && ret=0 + if (( $#suf )) && compset -P "<->"; then + _wanted ansi-colors expl 'closing brace' compadd -S '' \} && ret=0 + else + _message -e terminal-colors "number between 0 and $(( $terminfo[colors] - 1 ))" + fi +fi + +if compset -P '%[0-9-\\]#\(?'; then + compset -S '*' + _delimiters && ret=0 +elif compset -P '%[0-9-\\]#[<>\]]'; then + _message -e replacements 'replacement string' +elif compset -P '%[0-9-\\]#(\\|)\('; then + compset -S '[.:+/-%]*' || suf=( -S . ) + compset -S '*' + specs=( + '!:running with privileges' + '#:effective uid' + '?:exit status' + '_:at least n shell constructs started' + 'C:at least n path elements' + '/:at least n path elements' + '.:at least n path elements' + 'c:at least n path elements' + '~:at least n path elements' + 'D:month' + 'd:day of month' + 'g:effective gid' + 'j:number of jobs' + 'L:SHLVL' + 'l:number of characters already printed' + 'S:SECONDS parameter at least n' + 'T:current hour' + 't:current minute' + 'v:psvar has at least n elements' + 'V:element n of psvar is set and non-empty' + 'w:day of week (Sunday = 0)' + ) + _describe -t ternary-prompt-expressions 'ternary prompt format test character' specs $suf && ret=0 +elif compset -P '%D(\\|){'; then + compset -S '(\\|)}*' + _date_formats zsh && ret=0 +elif [[ -prefix '%' ]] || + ! zstyle -t ":completion:${curcontext}:prompt-format-specifiers" prefix-needed +then + specs=( + 'm:hostname up to first .' + '_:status of parser' + '^:reversed status of parser' + 'd:current working directory' + '/:current working directory' + '~:current working directory, with ~ replacement' + 'N:name of current script or shell function' + 'x:name of file containing code being executed' + 'c:deprecated' + '.:deprecated' + 'C:deprecated' + 'F:start using fg color' + 'K:start using bg color' + 'G:counts as extra character inside %{...%}' + '(:ternary expression %(x.true-string.false-string)' + ) + compset -P '%' || pre=( -p '%' ) + if ! compset -P '(-|)<->'; then + if [[ $service == -value-,SPROMPT,* ]]; then + specs+=( + 'r:suggested correction' + 'R:corrected string' + ) + fi + specs+=( + '%:A %' + '):A )' + 'l:current line (tty) with /dev/tty stripped' + 'M:full hostname' + 'n:username' + 'y:current line (tty)' + '#:a # when root, % otherwise' + '?:return status of last command' + 'h:current history event number' + '!:current history event number' + 'i:current line number' + 'I:current source line number' + 'j:number of jobs' + 'L:$SHLVL' + 'D:date in yy-mm-dd format' + 'T:current time of day, 24-hour format' + 't:current time of day, 12-hour am/pm format' + '@:current time of day, 12-hour am/pm format' + '*:current time of day, 24-hour format with seconds' + 'w:the date in day-dd format' + 'W:the date in mm/dd/yy format' + 'D{:format string like strftime' + 'B:start bold' + 'b:stop bold' + 'E:clear to end of line' + 'U:start underline' + 'u:stop underline' + 'S:start standout' + 's:stop standout' + 'f:reset fg color' + 'k:reset bg color' + '{:start literal escape sequence' + '}:stop literal escape sequence' + 'v:value from $psvar array' + '<:truncation from left %len<string<' + '>:truncation from right %len>string>' + '[:truncation from who knows where' + ) + fi + _describe -t prompt-format-specifiers 'prompt format specifier' \ + specs -S '' $pre && ret=0 + (( ! $#pre )) && [[ -prefix '(-|)<->' ]] && + _message -e prompt-format-specifiers number +fi + +return ret |