2005-09-20 13:31:55 +00:00
|
|
|
# Main file for fish command completions. This file contains various
|
|
|
|
# common helper functions for the command completions. All actual
|
|
|
|
# completions are located in the completions subdirectory.
|
2006-02-04 13:09:14 +00:00
|
|
|
#
|
|
|
|
# @configure_input@
|
2005-09-20 13:31:55 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Don't need completions in non-interactive mode
|
|
|
|
#
|
|
|
|
|
|
|
|
if not status --is-interactive
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
2005-11-03 14:35:35 +00:00
|
|
|
set -g fish_complete_path @SYSCONFDIR@/fish.d/completions ~/.fish.d/completions
|
2005-09-20 13:31:55 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Convenience functions
|
|
|
|
#
|
|
|
|
# The naming heuristic is that __fish_complete_* prints completions
|
|
|
|
# and descriptions, while __fish_print_* only prints the completion,
|
|
|
|
# without the description
|
|
|
|
#
|
|
|
|
|
|
|
|
function __fish_complete_users -d "Print a list of local users, with the real user name as a description"
|
|
|
|
cat /etc/passwd | sed -e "s/^\([^:]*\):[^:]*:[^:]*:[^:]*:\([^:]*\):.*/\1\t\2/"
|
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_complete_groups -d "Print a list of local groups, with group members as the description"
|
|
|
|
cat /etc/group | sed -e "s/^\([^:]*\):[^:]*:[^:]*:\(.*\)/\1\tMembers: \2/"
|
|
|
|
end
|
|
|
|
|
2006-01-16 15:01:10 +00:00
|
|
|
function __fish_complete_command -d "Complete using all available commands"
|
2006-01-30 16:51:50 +00:00
|
|
|
printf "%s\n" (commandline -ct)(complete -C (commandline -ct))
|
2006-01-16 15:01:10 +00:00
|
|
|
end
|
|
|
|
|
2005-09-20 13:31:55 +00:00
|
|
|
function __fish_print_interfaces -d "Print a list of known network interfaces"
|
|
|
|
netstat -i -n -a | awk 'NR>2'|awk '{print $1}'
|
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_print_addresses -d "Print a list of known network addresses"
|
|
|
|
/sbin/ifconfig |grep 'inet addr'|cut -d : -f 2|cut -d ' ' -f 1
|
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_print_users -d "Print a list of local users"
|
|
|
|
cat /etc/passwd | cut -d : -f 1
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Completions for the shell and it's builtin commands and functions
|
|
|
|
#
|
|
|
|
|
2006-01-05 13:41:59 +00:00
|
|
|
set -l __fish_help_desc (_ "Display help and exit")
|
2005-10-06 20:53:36 +00:00
|
|
|
for i in (builtin -n|grep -vE '(while|for|if|function|switch)' )
|
2006-01-05 13:41:59 +00:00
|
|
|
|
|
|
|
complete -c $i -s h -l help -d $__fish_help_desc
|
2005-09-20 13:31:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function __fish_append -d "Internal completion function for appending string to the commandline"
|
|
|
|
set separator $argv[1]
|
|
|
|
set -e argv[1]
|
2006-01-14 01:59:37 +00:00
|
|
|
set str (commandline -tc| sed -ne "s/\(.*$separator\)[^$separator]*/\1/p"|sed -e "s/--.*=//")
|
2006-01-13 01:02:45 +00:00
|
|
|
printf "%s\n" "$str"$argv "$str"(printf "%s\n" $argv|sed -e "s/\(\t\|\$\)/,\1/")
|
2005-09-20 13:31:55 +00:00
|
|
|
end
|
|
|
|
|
2006-02-02 15:31:51 +00:00
|
|
|
|
2006-02-10 00:43:14 +00:00
|
|
|
#
|
|
|
|
# Test to see if we've seen a subcommand from a list.
|
|
|
|
# This logic may seem backwards, but the commandline will often be much shorter
|
|
|
|
# than the list
|
|
|
|
#
|
|
|
|
|
|
|
|
function __fish_seen_subcommand_from
|
|
|
|
set -l -- cmd (commandline -poc)
|
|
|
|
set -e cmd[1]
|
|
|
|
for i in $cmd
|
|
|
|
if contains -- $i $argv
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2005-10-17 13:27:46 +00:00
|
|
|
#
|
|
|
|
# Completions for SysV startup scripts
|
|
|
|
#
|
2005-09-20 13:31:55 +00:00
|
|
|
|
2006-01-05 13:41:59 +00:00
|
|
|
complete -x -p "/etc/init.d/*" -a start\t(_ 'Start service')
|
|
|
|
complete -x -p "/etc/init.d/*" -a stop\t(_ 'Stop service')
|
|
|
|
complete -x -p "/etc/init.d/*" -a status\t(_ 'Print service status')
|
|
|
|
complete -x -p "/etc/init.d/*" -a restart\t(_ 'Stop and then start service')
|
|
|
|
complete -x -p "/etc/init.d/*" -a reload\t(_ 'Reload service configuration')
|
2005-09-20 13:31:55 +00:00
|
|
|
|