mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-04 06:09:39 +08:00
Add completions for the set builtin to handle completions of locale variables and locale names
darcs-hash:20060115200303-ac50b-c195155551b0b77ddf8b6ab5c3d3f9c6506a82b7.gz
This commit is contained in:
parent
645af56d77
commit
83629e28c8
@ -1,14 +1,22 @@
|
|||||||
|
#
|
||||||
|
# Completions for the 'set' builtin
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# We depend on set_color completions for color definitions
|
||||||
|
#
|
||||||
|
|
||||||
complete -y set_color
|
complete -y set_color
|
||||||
|
|
||||||
complete -c set -s e -l erase -d (_ "Erase variable")
|
#
|
||||||
complete -c set -s x -l export -d (_ "Export variable to subprocess")
|
# All locale variables used by set completions
|
||||||
complete -c set -s u -l unexport -d (_ "Do not export variable to subprocess")
|
#
|
||||||
complete -c set -s g -l global -d (_ "Make variable scope global")
|
|
||||||
complete -c set -s l -l local -d (_ "Make variable scope local")
|
set -g __fish_locale_vars LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
|
||||||
complete -c set -s U -l universal -d (_ "Make variable scope universal, i.e. share variable with all the users fish processes on this computer")
|
|
||||||
complete -c set -s q -l query -d (_ "Test if variable is defined")
|
#
|
||||||
complete -c set -s h -l help -d (_ "Display help and exit")
|
# Verious helper functions
|
||||||
|
#
|
||||||
|
|
||||||
function __fish_set_is_first -d 'Test if no non-switch argument has been specified yet'
|
function __fish_set_is_first -d 'Test if no non-switch argument has been specified yet'
|
||||||
set -- cmd (commandline -poc)
|
set -- cmd (commandline -poc)
|
||||||
@ -24,11 +32,9 @@ function __fish_set_is_first -d 'Test if no non-switch argument has been specifi
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
complete -c set -n '__fish_set_is_first' -x -a "(set|sed -e 's/ /\tVariable: /')"
|
|
||||||
|
|
||||||
function __fish_set_is_color -d 'Test if We are specifying a color value for the prompt'
|
function __fish_set_is_color -d 'Test if We are specifying a color value for the prompt'
|
||||||
set -- cmd (commandline -poc)
|
set cmd (commandline -poc)
|
||||||
set -e -- cmd[1]
|
set -e cmd[1]
|
||||||
for i in $cmd
|
for i in $cmd
|
||||||
switch $i
|
switch $i
|
||||||
|
|
||||||
@ -41,6 +47,46 @@ function __fish_set_is_color -d 'Test if We are specifying a color value for the
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function __fish_set_is_locale -d 'Test if We are specifying a locale value for the prompt'
|
||||||
|
set cmd (commandline -poc)
|
||||||
|
set -e cmd[1]
|
||||||
|
for i in $cmd
|
||||||
|
switch $i
|
||||||
|
|
||||||
|
case $__fish_locale_vars
|
||||||
|
return 0
|
||||||
|
|
||||||
|
case '-*'
|
||||||
|
|
||||||
|
case '*'
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Completions
|
||||||
|
#
|
||||||
|
|
||||||
|
complete -c set -s e -l erase -d (_ "Erase variable")
|
||||||
|
complete -c set -s x -l export -d (_ "Export variable to subprocess")
|
||||||
|
complete -c set -s u -l unexport -d (_ "Do not export variable to subprocess")
|
||||||
|
complete -c set -s g -l global -d (_ "Make variable scope global")
|
||||||
|
complete -c set -s l -l local -d (_ "Make variable scope local")
|
||||||
|
complete -c set -s U -l universal -d (_ "Make variable scope universal, i.e. share variable with all the users fish processes on this computer")
|
||||||
|
complete -c set -s q -l query -d (_ "Test if variable is defined")
|
||||||
|
complete -c set -s h -l help -d (_ "Display help and exit")
|
||||||
|
|
||||||
|
# Complete using preexisting variables
|
||||||
|
complete -c set -n '__fish_set_is_first' -x -a "(set|sed -e 's/ /\tVariable: /')"
|
||||||
|
|
||||||
|
# Color completions
|
||||||
complete -c set -n '__fish_set_is_color' -x -a '(set_color --print-colors)' -d (_ Color)
|
complete -c set -n '__fish_set_is_color' -x -a '(set_color --print-colors)' -d (_ Color)
|
||||||
|
|
||||||
|
# Locale completions
|
||||||
|
complete -c set -n '__fish_set_is_first' -x -a '$__fish_locale_vars' -d 'Locale variable'
|
||||||
|
complete -c set -n '__fish_set_is_locale' -x -a '(locale -a)' -d (_ Locale)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user