mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
completions/set: offer private variables if token starts with _
This commit is contained in:
parent
18f6492564
commit
33701faa8c
|
@ -93,9 +93,18 @@ complete -c set -n "__fish_is_nth_token 1" -l unpath -d "Make variable not as a
|
|||
#TODO: add CPP code to generate list of read-only variables and exclude them from the following completions
|
||||
|
||||
# Complete using preexisting variable names
|
||||
complete -c set -n '__fish_is_nth_token 1; 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_nth_token 1; 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 -r '^((?:history|fish_killring) ) .*' '$1' | string replace ' ' \t'Global Variable: ')"
|
||||
complete -c set -n '__fish_is_nth_token 1; 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: ')"
|
||||
set -l maybe_filter_private_vars '
|
||||
string match (
|
||||
if string match -qr -- "^_" "$(commandline -t)": then
|
||||
echo "*"
|
||||
else
|
||||
echo -rv
|
||||
echo "^__"
|
||||
end
|
||||
)'
|
||||
complete -c set -n '__fish_is_nth_token 1; 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 | $maybe_filter_private_vars | string replace ' ' \t'Local Variable: ')"
|
||||
complete -c set -n '__fish_is_nth_token 1; 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 | $maybe_filter_private_vars | string replace -r '^((?:history|fish_killring) ).*' '$1' | string replace ' ' \t'Global Variable: ')"
|
||||
complete -c set -n '__fish_is_nth_token 1; 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 | $maybe_filter_private_vars | string replace ' ' \t'Universal Variable: ')"
|
||||
# Complete some fish configuration variables even if they aren't set.
|
||||
complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase' -x -a "(__fish_complete_special_vars)"
|
||||
# Complete scope-specific variables
|
||||
|
|
Loading…
Reference in New Issue
Block a user