fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a9618477e
master
1function __fish_eselect_cmd 2eselect --brief --colour=no$argv 3end 4 5function __fish_complete_eselect_modules 6set -l sedregexp's/^ ([a-zA-Z0-9_-]*)[ ]*/\1\t/g' 7__fish_eselect_cmd modules list| string match -r'^ ' | sed -r$sedregexp 8end 9 10function __fish_complete_eselect_actions 11set -l sedregexp's/^ ([a-zA-Z0-9_-]*)[ ]*/\1\t/g' 12set -l cmdl( commandline -pxc) 13__fish_eselect_cmd $cmdl [ 2 .. -1 ] usage| string match -r'^ [^ -]' | sed -r$sedregexp 14end 15 16function __fish_complete_eselect_action_options 17set -l parseregexp's/^ ([a-zA-Z0-9_-]*)[ ]*/\1\t/g' 18set -l cmdl( commandline -pxc) 19 20# Alter further php completion 21if test ( __fish_print_cmd_args_without_options )[ 2 ] = php 22eselect php list-modules2> /dev/null| string split" " 23return 24end 25 26switch $cmdl [ -1 ] 27case -'*' 28return 29end 30 31set -l findregexp'/^ ' $cmdl [ -1 ] '/,/^ [^ ]/p' 32 33set cmdl[ -1 ] usage 34__fish_eselect_cmd $cmdl [ 2 .. -1 ] | sed -n -re$findregexp | string match -r'^ --' | sed -re$parseregexp 35end 36 37function __fish_complete_eselect_php_actions 38set -l sedregexp's/^\s*\[([0-9]+)\]\s+([A-Za-z0-9\.]+).*/\1\t\2/' 39 40if test ( __fish_print_cmd_args_without_options )[ 3 ] = set 41eselect php list( __fish_print_cmd_args_without_options )[ -1 ] 2> /dev/null| sed -r$sedregexp 42end 43end 44 45function __fish_complete_eselect_targets 46set -l sedregexp's/^ \[([0-9]+)\][ ]*/\1\t/g' 47set -l cmdl( commandline -pxc) 48 49# Disable further php completion 50if test ( __fish_print_cmd_args_without_options )[ 2 ] = php 51return 52end 53 54switch $cmdl [ -1 ] 55case -'*' 56set cmdl[ -2 ] list 57case '*' 58set cmdl[ -1 ] list 59end 60 61eselect --colour=no$cmdl [ 2 .. -1 ] | string match -r'^ [^ -]' | sed -r$sedregexp 62end 63 64complete -c eselect -n"test (__fish_number_of_cmd_args_wo_opts) = 1" \ 65 -xa'(__fish_complete_eselect_modules)' 66 67complete -c eselect -n"test (__fish_number_of_cmd_args_wo_opts) = 1" \ 68 -l brief -d'Make output shorter' 69 70complete -c eselect -n"test (__fish_number_of_cmd_args_wo_opts) = 1" \ 71 -l colour\ 72 -d"=<yes|no|auto> Enable or disable colour output (default 'auto')" 73 74complete -c eselect -n"test (__fish_number_of_cmd_args_wo_opts) = 2" \ 75 -xa'(__fish_complete_eselect_actions)' 76 77complete -c eselect -n"test (__fish_number_of_cmd_args_wo_opts) = 3" \ 78 -xa'(__fish_complete_eselect_targets)' 79 80complete -c eselect -n"test (__fish_number_of_cmd_args_wo_opts) = 3" \ 81 -xa'(__fish_complete_eselect_action_options)' 82 83complete -c eselect -n"test (__fish_number_of_cmd_args_wo_opts) = 4" \ 84 -xa'(__fish_complete_eselect_php_actions)'