Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: add completer for $PROMPT
- X-seq: zsh-workers 29427
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: add completer for $PROMPT
- Date: Wed, 1 Jun 2011 20:11:01 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:message-id:x-mailer; bh=JpJMISHcUphzUOZVp5h5MGr5hhU0OVMlqe7hzC5Fau0=; b=jnPWrfDNFbsL8KGx0l+A0CA4kJtsSdUFuhEb1zXCsMbmgV/mL0dQoivaAh5RajkDKt buQF+P6JUqJzswDx+dm5o1ace4qj/0bZfX76lJ9n47O44QEtOF+SfEBHS8DBS8BcynZX ForZKWMb66n/XhCfBjNVK9nohIUm856KXwTs4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer; b=GTUxoEDp8/L2a7tqGr/sYpZbJfleuenVQoroYTvvIvf9A9ckQm93Fs+28uKkfLjG+a t2c3wDdhaGnU5MvoRV8UQj0BLczFBxYXgwPLUCZ4IChHKqp5bIseZb9EnnFhG2zL8lIr bQhlDB9xgsMtB9PzkV7d5smjz8eX+gBDN+yQ8=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
I thought I'd throw something quick together, but I ended up doing this
instead. The descriptions could probably use some work, but I'm not
going to bother unless people think it's a good idea.
---
Completion/Unix/Type/.distfiles | 1 +
Completion/Unix/Type/_ps1234 | 102 +++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+), 0 deletions(-)
create mode 100644 Completion/Unix/Type/_ps1234
diff --git a/Completion/Unix/Type/.distfiles b/Completion/Unix/Type/.distfiles
index 4c0d688..a9dc0d1 100644
--- a/Completion/Unix/Type/.distfiles
+++ b/Completion/Unix/Type/.distfiles
@@ -36,6 +36,7 @@ _pids
_ports
_printers
_ps
+_ps1234
_pspdf
_services
_signals
diff --git a/Completion/Unix/Type/_ps1234 b/Completion/Unix/Type/_ps1234
new file mode 100644
index 0000000..fe98f3a
--- /dev/null
+++ b/Completion/Unix/Type/_ps1234
@@ -0,0 +1,102 @@
+#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-
+
+local -a specs
+local expl paren
+
+if [[ -n $compstate[quote] ]]; then
+ paren='('
+else
+ paren='\('
+fi
+
+if [[ $PREFIX == *%<-># ]]; then
+ specs=(
+ 'm:hostname up to first .'
+ '_: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 %{...%}'
+ )
+ if [[ $PREFIX == *% ]]; then
+ 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'
+ '(:ternary expression %(x.true-string.false-string)'
+ '<<:truncation from left %len<string<'
+ '>>:truncation from right %len>string>'
+ '[]:truncation from who knows where'
+ )
+ fi
+ compset -P "*"
+ _describe -t prompt-format-specifier 'prompt format specifier' specs -S ''
+ _message -e prompt-format-specifier number
+elif [[ $PREFIX == *%$paren<-># ]]; then
+ 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)'
+ )
+ compset -P "*"
+ _describe -t ternary-prompt-expression 'ternary prompt format test character' specs -S ''
+ _message -e ternary-prompt-expression number
+else
+ _files "$@"
+fi
--
1.7.4-rc1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author