diff options
Diffstat (limited to 'Completion/Base')
-rw-r--r-- | Completion/Base/_command_names | 3 | ||||
-rw-r--r-- | Completion/Base/_condition | 10 | ||||
-rw-r--r-- | Completion/Base/_default | 13 | ||||
-rw-r--r-- | Completion/Base/_match_pattern | 31 | ||||
-rw-r--r-- | Completion/Base/_match_test | 15 | ||||
-rw-r--r-- | Completion/Base/_precommand | 5 | ||||
-rw-r--r-- | Completion/Base/_redirect | 3 | ||||
-rw-r--r-- | Completion/Base/_subscript | 4 | ||||
-rw-r--r-- | Completion/Base/_vars | 3 |
9 files changed, 87 insertions, 0 deletions
diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names new file mode 100644 index 000000000..d3b8a109a --- /dev/null +++ b/Completion/Base/_command_names @@ -0,0 +1,3 @@ +#defcomp -command- + +complist -c diff --git a/Completion/Base/_condition b/Completion/Base/_condition new file mode 100644 index 000000000..3e45e1b8f --- /dev/null +++ b/Completion/Base/_condition @@ -0,0 +1,10 @@ +#defcomp -condition- + +if [[ -current -1 -o ]]; then + complist -o -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' +elif [[ -current -1 -nt || -current -1 -ot || -current -1 -ef ]]; then + _files +else + _files + complist -v +fi diff --git a/Completion/Base/_default b/Completion/Base/_default new file mode 100644 index 000000000..8bcf14f6a --- /dev/null +++ b/Completion/Base/_default @@ -0,0 +1,13 @@ +#defcomp -default- + +# We first try the `compctl's. This is without first (-T) and default (-D) +# completion. If you want them add `-T' and/or `-D' to this command. +# If there is a `compctl' for the command we are working on, we return +# immediatly. If you want to use new style completion anyway, remove the +# `|| return'. Also, you may want to use new style completion if the +# `compctl' didn't produce any matches. In that case remove the `|| return' +# and at the line `[[ -nmatches 0 ]] || return' after `compcall'. + +compcall || return + +_files diff --git a/Completion/Base/_match_pattern b/Completion/Base/_match_pattern new file mode 100644 index 000000000..c5debc0b9 --- /dev/null +++ b/Completion/Base/_match_pattern @@ -0,0 +1,31 @@ +#autoload + +# This function is called from functions that do matching whenever they +# need to build a pattern that is used to match possible completions. +# It gets the name of the calling function and two names of parameters +# as arguments. The first one is used in the calling function to build +# the pattern used for matching possible completions. The content of this +# parameter on entry to this function is the string taken from the line. +# Here it parameter should be changed to a pattern that matches words as +# the match specs currently in use do. +# In the calling function this pattern may be changed again or used only +# in parts. The second parameter whose name is given as the third argument +# allows to give pattern flags liek `(#l)' that are to be used whenever +# matching is done. +# +# As an example, if you have global match specifications like: +# +# compctl -M 'm:{a-z}={A-Z}' 'm:{a-z}={A-Z} r:|[.-]=* r:|=*' +# +# This function would look like: +# +# eval "${3}='(#l)'" +# [[ MATCHER -eq 2 ]] && eval "$1='${(P)2:gs/./*./:gs/-/*-/}'" +# +# The first line makes sure that matching is done case-insensitive as +# specified by `m:{a-z}={A-Z}'. The second line replaces dots and hyphens +# in the given string by patterns matching any characters before them, +# like the `r:|[.-]=* r:|=*'. To make this work, the function `_match_test' +# would have to be changed to `(( MATCHERS <= 2 ))' +# +# The default implementation of this function is empty. diff --git a/Completion/Base/_match_test b/Completion/Base/_match_test new file mode 100644 index 000000000..e8b6e6424 --- /dev/null +++ b/Completion/Base/_match_test @@ -0,0 +1,15 @@ +#autoload + +# This function is called at the beginning of functions that do matching in +# shell code. It should test the value of the `MATCHER' special parameter +# and return non-zero if the calling function should try to generate matches +# for the global match specification in use. +# +# This function gets one argument, the name of the function calling it. +# +# If you have a global match specification with more than one set of patterns +# you may want to modify this function to return non-zero for all of your +# match specifications and modify the function `_match_pattern' to build the +# pattern to use in the calling function. + +(( MATCHER == 1 )) diff --git a/Completion/Base/_precommand b/Completion/Base/_precommand new file mode 100644 index 000000000..2cf661147 --- /dev/null +++ b/Completion/Base/_precommand @@ -0,0 +1,5 @@ +#defcomp - nohup nice eval time rusage noglob nocorrect exec + +[[ -position 1 -1 ]] + +_normal "$@" diff --git a/Completion/Base/_redirect b/Completion/Base/_redirect new file mode 100644 index 000000000..32113ad7c --- /dev/null +++ b/Completion/Base/_redirect @@ -0,0 +1,3 @@ +#defcomp -redirect- + +_files diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript new file mode 100644 index 000000000..2b827a117 --- /dev/null +++ b/Completion/Base/_subscript @@ -0,0 +1,4 @@ +#defcomp -subscript- + +_compalso -math- "$@" +[[ ${(Pt)${COMMAND}} = assoc* ]] && complist -k "( ${(kP)${COMMAND}} )" diff --git a/Completion/Base/_vars b/Completion/Base/_vars new file mode 100644 index 000000000..7153b6f38 --- /dev/null +++ b/Completion/Base/_vars @@ -0,0 +1,3 @@ +#defcomp -math- getopts read unset vared + +complist -v |