2013-11-19 18:45:21 +00:00
|
|
|
function __fish_eselect_cmd
|
|
|
|
eselect --brief --colour=no $argv
|
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_complete_eselect_modules
|
|
|
|
set -l sedregexp 's/^ ([a-zA-Z0-9_-]*)[ ]*/\1\t/g'
|
2017-04-16 04:01:03 +00:00
|
|
|
__fish_eselect_cmd modules list | string match -r '^ ' | sed -r $sedregexp
|
2013-11-19 18:45:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_complete_eselect_actions
|
|
|
|
set -l sedregexp 's/^ ([a-zA-Z0-9_-]*)[ ]*/\1\t/g'
|
|
|
|
set -l cmdl (commandline -poc)
|
2017-04-16 04:01:03 +00:00
|
|
|
__fish_eselect_cmd $cmdl[2..-1] usage | string match -r '^ [^ -]' | sed -r $sedregexp
|
2013-11-19 18:45:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_complete_eselect_action_options
|
|
|
|
set -l parseregexp 's/^ ([a-zA-Z0-9_-]*)[ ]*/\1\t/g'
|
|
|
|
set -l cmdl (commandline -poc)
|
|
|
|
|
2016-01-24 14:45:56 +00:00
|
|
|
# Alter further php completion
|
2013-11-19 18:45:21 +00:00
|
|
|
if [ (__fish_print_cmd_args_without_options)[2] = 'php' ]
|
2016-02-04 22:31:32 +00:00
|
|
|
eselect php list-modules ^/dev/null | string split " "
|
2013-11-19 18:45:21 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
switch $cmdl[-1]
|
|
|
|
case -'*'
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
set -l findregexp '/^ '$cmdl[-1]'/,/^ [^ ]/p'
|
|
|
|
|
|
|
|
set cmdl[-1] usage
|
2017-04-16 04:01:03 +00:00
|
|
|
__fish_eselect_cmd $cmdl[2..-1] | sed -n -re $findregexp | string match -r '^ --' | sed -re $parseregexp
|
2013-11-19 18:45:21 +00:00
|
|
|
end
|
|
|
|
|
2016-01-24 14:45:56 +00:00
|
|
|
function __fish_complete_eselect_php_actions
|
|
|
|
set -l sedregexp 's/^\s*\[([0-9]+)\]\s+([A-Za-z0-9\.]+).*/\1\t\2/'
|
|
|
|
|
|
|
|
if test (__fish_print_cmd_args_without_options)[3] = 'set'
|
2016-02-04 22:31:32 +00:00
|
|
|
eselect php list (__fish_print_cmd_args_without_options)[-1] ^/dev/null | sed -r $sedregexp
|
2016-01-24 14:45:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-19 18:45:21 +00:00
|
|
|
function __fish_complete_eselect_targets
|
|
|
|
set -l sedregexp 's/^ \[([0-9]+)\][ ]*/\1\t/g'
|
|
|
|
set -l cmdl (commandline -poc)
|
|
|
|
|
|
|
|
# Disable further php completion
|
|
|
|
if [ (__fish_print_cmd_args_without_options)[2] = 'php' ]
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
switch $cmdl[-1]
|
|
|
|
case -'*'
|
|
|
|
set cmdl[-2] list
|
|
|
|
case '*'
|
|
|
|
set cmdl[-1] list
|
|
|
|
end
|
|
|
|
|
2017-04-16 04:01:03 +00:00
|
|
|
eselect --colour=no $cmdl[2..-1] | string match -r '^ [^ -]' | sed -r $sedregexp
|
2013-11-19 18:45:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
complete -c eselect -n "test (__fish_number_of_cmd_args_wo_opts) = 1" \
|
|
|
|
-xa '(__fish_complete_eselect_modules)'
|
|
|
|
|
|
|
|
complete -c eselect -n "test (__fish_number_of_cmd_args_wo_opts) = 1" \
|
|
|
|
-l brief -d 'Make output shorter'
|
|
|
|
|
|
|
|
complete -c eselect -n "test (__fish_number_of_cmd_args_wo_opts) = 1" \
|
|
|
|
-l colour \
|
|
|
|
-d "=<yes|no|auto> Enable or disable colour output (default 'auto')"
|
|
|
|
|
|
|
|
complete -c eselect -n "test (__fish_number_of_cmd_args_wo_opts) = 2" \
|
|
|
|
-xa '(__fish_complete_eselect_actions)'
|
|
|
|
|
|
|
|
complete -c eselect -n "test (__fish_number_of_cmd_args_wo_opts) = 3" \
|
|
|
|
-xa '(__fish_complete_eselect_targets)'
|
|
|
|
|
|
|
|
complete -c eselect -n "test (__fish_number_of_cmd_args_wo_opts) = 3" \
|
|
|
|
-xa '(__fish_complete_eselect_action_options)'
|
|
|
|
|
2016-01-24 14:45:56 +00:00
|
|
|
complete -c eselect -n "test (__fish_number_of_cmd_args_wo_opts) = 4" \
|
|
|
|
-xa '(__fish_complete_eselect_php_actions)'
|