mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
only check previous words in bash completion
This commit is contained in:
@ -23,7 +23,7 @@ _jc()
|
|||||||
_get_comp_words_by_ref cur prev words cword
|
_get_comp_words_by_ref cur prev words cword
|
||||||
|
|
||||||
# if jc_about_options are found anywhere in the line, then only complete from jc_about_mod_options
|
# if jc_about_options are found anywhere in the line, then only complete from jc_about_mod_options
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]::$${#words[@]}-1}"; do
|
||||||
if [[ " $${jc_about_options[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_about_options[*]} " =~ " $${i} " ]]; then
|
||||||
COMPREPLY=( $$( compgen -W "$${jc_about_mod_options[*]}" \\
|
COMPREPLY=( $$( compgen -W "$${jc_about_mod_options[*]}" \\
|
||||||
-- "$${cur}" ) )
|
-- "$${cur}" ) )
|
||||||
@ -34,14 +34,14 @@ _jc()
|
|||||||
# if jc_help_options and a parser are found anywhere in the line, then no more completions
|
# if jc_help_options and a parser are found anywhere in the line, then no more completions
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]::$${#words[@]}-1}"; do
|
||||||
if [[ " $${jc_help_options[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_help_options[*]} " =~ " $${i} " ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
) && (
|
) && (
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]::$${#words[@]}-1}"; do
|
||||||
if [[ " $${jc_parsers[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_parsers[*]} " =~ " $${i} " ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -52,7 +52,7 @@ _jc()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# if jc_help_options are found anywhere in the line, then only complete with parsers
|
# if jc_help_options are found anywhere in the line, then only complete with parsers
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]::$${#words[@]}-1}"; do
|
||||||
if [[ " $${jc_help_options[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_help_options[*]} " =~ " $${i} " ]]; then
|
||||||
COMPREPLY=( $$( compgen -W "$${jc_parsers[*]}" \\
|
COMPREPLY=( $$( compgen -W "$${jc_parsers[*]}" \\
|
||||||
-- "$${cur}" ) )
|
-- "$${cur}" ) )
|
||||||
@ -61,14 +61,14 @@ _jc()
|
|||||||
done
|
done
|
||||||
|
|
||||||
# if special options are found anywhere in the line, then no more completions
|
# if special options are found anywhere in the line, then no more completions
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]::$${#words[@]}-1}"; do
|
||||||
if [[ " $${jc_special_options[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_special_options[*]} " =~ " $${i} " ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# if magic command is found anywhere in the line, use called command's autocompletion
|
# if magic command is found anywhere in the line, use called command's autocompletion
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]::$${#words[@]}-1}"; do
|
||||||
if [[ " $${jc_commands[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_commands[*]} " =~ " $${i} " ]]; then
|
||||||
_command
|
_command
|
||||||
return 0
|
return 0
|
||||||
@ -76,7 +76,7 @@ _jc()
|
|||||||
done
|
done
|
||||||
|
|
||||||
# if a parser arg is found anywhere in the line, only show options and help options
|
# if a parser arg is found anywhere in the line, only show options and help options
|
||||||
for i in "$${words[@]}"; do
|
for i in "$${words[@]::$${#words[@]}-1}"; do
|
||||||
if [[ " $${jc_parsers[*]} " =~ " $${i} " ]]; then
|
if [[ " $${jc_parsers[*]} " =~ " $${i} " ]]; then
|
||||||
COMPREPLY=( $$( compgen -W "$${jc_options[*]} $${jc_help_options[*]}" \\
|
COMPREPLY=( $$( compgen -W "$${jc_options[*]} $${jc_help_options[*]}" \\
|
||||||
-- "$${cur}" ) )
|
-- "$${cur}" ) )
|
||||||
|
Reference in New Issue
Block a user