Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Add sketchy parameter flags completion



I don't intend to commit this, but I thought I'd post it anyway, I
find it pretty useful. It needs some more special handling stuff like
_glob_quals has.

---
 Completion/Unix/Type/_path_files     |    5 +++
 Completion/Zsh/Type/_parameter_flags |   55 ++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)
 create mode 100644 Completion/Zsh/Type/_parameter_flags

diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index 1c272ba..d3bae03 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -2,6 +2,11 @@
 
 local -a match mbegin mend
 
+if [[ $PREFIX = *\$\{\([^\)]# ]]; then
+  _parameter_flags
+  return
+fi
+
 # Look for glob qualifiers.  Do this first:  if we're really
 # in a glob qualifier, we don't actually want to expand
 # the earlier part of the path.  We can't expand inside
diff --git a/Completion/Zsh/Type/_parameter_flags b/Completion/Zsh/Type/_parameter_flags
new file mode 100644
index 0000000..24d00b4
--- /dev/null
+++ b/Completion/Zsh/Type/_parameter_flags
@@ -0,0 +1,55 @@
+#autoload
+
+local -a flags
+
+flags=(
+  "#:show result as character (printf %c)"
+  "%:expand % escapes as in prompts"
+  "@:separate array elements when double quoted"
+  "A:create array parameter, associative when repeated"
+  "a:sort in array index order"
+  "c:with \${#name} count total characters in array with spaces"
+  "C:capitalize words"
+  "D:reverse ~ substitution"
+  "e:perform expansion on result"
+  "f:split expansion on newlines, ps:\\n:"
+  "F:join array with newlines, pj:\\n:"
+  "i:sort case-insensitively"
+  "k:substitute keys or indices instead of values"
+  "L:lowercase words"
+  "n:numeric sort"
+  "o:sort in ascending order"
+  "O:sort in descending order"
+  "P:interpret expansion as parameter name"
+  "q:quote expansion, repeat for variations"
+  "q-:minimal quoting"
+  "Q:remove one level of quoting"
+  "t:describe parameter"
+  "u:expand only unique words"
+  "U:uppercase words"
+  "v:with k, substitute both key and value, otherwise force value expansion"
+  "V:make special characters readable"
+  "w:with \${#name} count words, use s to set delimiter"
+  "W:like w but count also empty words"
+  "X:report errors"
+  "z:split into words by shell parsing"
+  "0:split expansion on null bytes, ps:\\0:"
+  "p:recognize escape sequences in arguments to further flags"
+  "~:treat string arguments to further flags as patterns"
+  "j:join words of arrays using separator"
+  "l:pad words on left, l:expr:[:string1:][:string2:]"
+  "m:report width rather than length of strings"
+  "mm:report number of visible characters"
+  "r:pad words on right, r:expr:[:string1:][:string2:]"
+  "s:field split into array using separator"
+  "S:non-greedy matching with / or //, search substrings with # or %"
+  "I:search the :expr:th match"
+  "B:index of the beginning of match"
+  "E:index of the end of match"
+  "M:matched portion"
+  "N:length of match"
+  "R:unmatched portion"
+  )
+
+compset -P '*'
+_describe -t paramflags "parameter flag" flags -Q -S ''
-- 
1.7.4-rc1



Messages sorted by: Reverse Date, Date, Thread, Author