2006-01-16 04:03:03 +08:00
#
# Completions for the 'set' builtin
#
#
# All locale variables used by set completions
#
set -g __fish_locale_vars LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
#
2006-01-16 23:01:10 +08:00
# Various helper functions
2006-01-16 04:03:03 +08:00
#
2005-09-20 21:31:55 +08:00
function __fish_set_is_color -d 'Test if We are specifying a color value for the prompt'
2020-05-15 13:56:06 +08:00
set -l cmd ( commandline -poc )
2019-05-05 18:53:09 +08:00
set -e cmd [ 1 ]
for i in $cmd
switch $i
2005-09-20 21:31:55 +08:00
2019-05-05 18:53:09 +08:00
case 'fish_color_*' 'fish_pager_color_*'
return 0
2005-09-20 21:31:55 +08:00
2019-05-05 18:53:09 +08:00
case '-*'
2010-09-18 10:18:26 +08:00
2019-05-05 18:53:09 +08:00
case '*'
return 1
end
end
return 1
2005-09-20 21:31:55 +08:00
end
2006-01-16 04:03:03 +08:00
function __fish_set_is_locale -d 'Test if We are specifying a locale value for the prompt'
2020-05-15 13:56:06 +08:00
set -l cmd ( commandline -poc )
2019-05-05 18:53:09 +08:00
set -e cmd [ 1 ]
for i in $cmd
switch $i
case $__fish_locale_vars
return 0
case '-*'
continue
case '*'
return 1
end
end
return 1
2006-01-16 04:03:03 +08:00
end
2019-05-21 23:00:32 +08:00
function __fish_set_special_vars
printf %s\t %s\n CDPATH "A list of dirs that cd uses"
printf %s\t %s\n fish_emoji_width "How wide your terminal displays emoji (2 since Unicode 9, 1 previously)"
printf %s\t %s\n fish_ambiguous_width "How wide your terminal displays ambiguous chars (1 or 2)"
printf %s\t %s\n fish_escape_delay_ms "How long fish waits to distinguish escape and alt"
printf %s\t %s\n fish_greeting "The message to display at start (also a function)"
printf %s\t %s\n fish_history "The session id to store history under"
2020-05-03 08:18:23 +08:00
printf %s\t %s\n fish_trace "Enables execution tracing (if set to non-empty value)"
2019-05-21 23:00:32 +08:00
printf %s\t %s\n fish_user_paths "A list of dirs to prepend to PATH"
printf %s\t %s\n BROWSER "The browser to use"
end
2006-01-16 04:03:03 +08:00
#
# Completions
#
2006-01-18 03:34:50 +08:00
# Regular switches, set only accepts these before the variable name,
# so we need to test using __fish_is_first_token
2020-03-10 02:36:12 +08:00
complete -c set -n __fish_is_first_token -s e -l erase -d "Erase variable"
complete -c set -n __fish_is_first_token -s x -l export -d "Export variable to subprocess"
complete -c set -n __fish_is_first_token -s u -l unexport -d "Do not export variable to subprocess"
complete -c set -n __fish_is_first_token -s g -l global -d "Make variable scope global"
complete -c set -n __fish_is_first_token -s l -l local -d "Make variable scope local"
complete -c set -n __fish_is_first_token -s U -l universal -d "Share variable persistently across sessions"
complete -c set -n __fish_is_first_token -s q -l query -d "Test if variable is defined"
complete -c set -n __fish_is_first_token -s h -l help -d "Display help and exit"
complete -c set -n __fish_is_first_token -s n -l names -d "List the names of the variables, but not their value"
complete -c set -n __fish_is_first_token -s a -l append -d "Append value to a list"
complete -c set -n __fish_is_first_token -s p -l prepend -d "Prepend value to a list"
complete -c set -n __fish_is_first_token -s S -l show -d "Show variable"
2020-05-14 01:42:41 +08:00
complete -c set -n __fish_is_first_token -l path -d "Make variable as a path variable"
complete -c set -n __fish_is_first_token -l unpath -d "Make variable not as a path variable"
2006-08-31 23:44:00 +08:00
2018-04-04 03:40:51 +08:00
#TODO: add CPP code to generate list of read-only variables and exclude them from the following completions
2006-01-18 03:34:50 +08:00
# Complete using preexisting variable names
2019-04-16 03:57:59 +08:00
complete -c set -n '__fish_is_first_token; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -l | string match -rv '^__' | string replace ' ' \t'Local Variable: ')"
complete -c set -n '__fish_is_first_token; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -g | string match -rv '^__' | string replace ' ' \t'Global Variable: ')"
complete -c set -n '__fish_is_first_token; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -U | string match -rv '^__' | string replace ' ' \t'Universal Variable: ')"
2019-05-21 23:00:32 +08:00
# Complete some fish configuration variables even if they aren't set.
complete -c set -n '__fish_is_first_token; and not __fish_seen_argument -s e -l erase' -x -a "(__fish_set_special_vars)"
2018-04-04 03:40:51 +08:00
# Complete scope-specific variables
2020-06-20 15:51:29 +08:00
complete -c set -n '__fish_is_first_token; and __fish_seen_argument -s l -l local' -x -a "(set -l | string replace ' ' \t'Local Variable: ')"
complete -c set -n '__fish_is_first_token; and __fish_seen_argument -s g -l global' -x -a "(set -g | string replace ' ' \t'Global Variable: ')"
complete -c set -n '__fish_is_first_token; and __fish_seen_argument -s U -l universal' -x -a "(set -U | string replace ' ' \t'Universal Variable: ')"
2018-04-04 03:40:51 +08:00
# Complete using preexisting variable names for `set --erase`
2020-06-20 15:51:29 +08:00
complete -c set -n '__fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s U -s g -l local -l global -l Universal' -f -a "(set -g | string replace ' ' \tGlobal\ Variable:\ )"
complete -c set -n '__fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s U -s g -l local -l global -l Universal' -f -a "(set -l | string replace ' ' \tLocal\ Variable:\ )"
complete -c set -n '__fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s U -s g -l local -l global -l Universal' -f -a "(set -U | string replace ' ' \tUniversal\ Variable:\ )"
2018-04-04 03:40:51 +08:00
# Complete scope-specific variables for `set --erase`
2020-06-20 15:51:29 +08:00
complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument -s g -l global' -f -a "(set -g | string replace ' ' \t'Global Variable: ')"
complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument -s U -l universal' -f -a "(set -U | string replace ' ' \t'Universal Variable: ')"
complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument -s l -l local' -f -a "(set -l | string replace ' ' \t'Local Variable: ')"
2006-01-16 04:03:03 +08:00
# Color completions
2020-03-10 02:36:12 +08:00
complete -c set -n __fish_set_is_color -x -a '(set_color --print-colors)'
complete -c set -n __fish_set_is_color -s b -l background -x -a '(set_color --print-colors)' -d "Change background color"
complete -c set -n __fish_set_is_color -s o -l bold -d 'Make font bold'
2006-01-16 04:03:03 +08:00
# Locale completions
2020-03-10 02:36:12 +08:00
complete -c set -n '__fish_set_is_locale; and not __fish_seen_argument -s e -l erase' -x -a '(command -sq locale; and locale -a)' -d Locale
2012-08-24 21:06:02 +08:00
complete -c set -s L -l long -d 'Do not truncate long lines'