Add a __fish_complete_command function for completing using a command name. Change name of the __fish_set_is_first to __fish_is_first_token and move it to the common completion util file

darcs-hash:20060116150110-ac50b-d864b516887c8fae941a745186dc308d50113c23.gz
This commit is contained in:
axel 2006-01-17 01:01:10 +10:00
parent e593f9be53
commit 5bd66ee2ce
2 changed files with 22 additions and 17 deletions

View File

@ -15,23 +15,9 @@ complete -y set_color
set -g __fish_locale_vars LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
#
# Verious helper functions
# Various helper functions
#
function __fish_set_is_first -d 'Test if no non-switch argument has been specified yet'
set -- cmd (commandline -poc)
set -e -- cmd[1]
for i in $cmd
switch $i
case '-*'
case '*'
return 1;
end
end
return 0
end
function __fish_set_is_color -d 'Test if We are specifying a color value for the prompt'
set cmd (commandline -poc)
set -e cmd[1]
@ -82,11 +68,11 @@ 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: /')"
complete -c set -n '__fish_is_first_token' -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)
# Locale completions
complete -c set -n '__fish_set_is_first' -x -a '$__fish_locale_vars' -d 'Locale variable'
complete -c set -n '__fish_is_first_token' -x -a '$__fish_locale_vars' -d 'Locale variable'
complete -c set -n '__fish_set_is_locale' -x -a '(locale -a)' -d (_ Locale)

View File

@ -95,6 +95,11 @@ function __fish_complete_pids -d "Print a list of process identifiers along with
# pgrep -l -v -P %self | sed 's/ /\t/'
end
function __fish_complete_command -d "Complete using all available commands"
for i in $PATH; command ls $i; end
end
function __fish_print_hostnames -d "Print a list of known hostnames"
# Print all hosts from /etc/hosts
@ -266,6 +271,20 @@ function __fish_gnu_complete -d "Wrapper for the complete builtin. Skips the lon
end
function __fish_is_first_token -d 'Test if no non-switch argument has been specified yet'
set -- cmd (commandline -poc)
set -e -- cmd[1]
for i in $cmd
switch $i
case '-*'
case '*'
return 1;
end
end
return 0
end
#
# Completions for SysV startup scripts
#