2006-02-17 10:13:39 +00:00
|
|
|
#
|
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
|
|
|
#
|
2006-07-18 16:41:55 +00:00
|
|
|
# @configure_input@
|
2006-02-17 10:13:39 +00:00
|
|
|
|
2006-10-04 17:55:19 +00:00
|
|
|
#
|
|
|
|
# Set default search paths for completions and shellscript functions
|
|
|
|
# unless they already exist
|
|
|
|
#
|
|
|
|
|
|
|
|
if not set -q fish_function_path
|
|
|
|
set -U fish_function_path ~/.fish.d/functions @sysconfdir@/fish.d/functions @datadir@/fish/functions
|
|
|
|
end
|
|
|
|
|
|
|
|
if not set -q fish_complete_path
|
|
|
|
set -U fish_complete_path ~/.fish.d/completions @sysconfdir@/fish.d/completions @datadir@/fish/completions
|
|
|
|
end
|
|
|
|
|
2006-08-10 19:33:38 +00:00
|
|
|
set __fish_help_dir @docdir@
|
|
|
|
|
2006-07-31 00:31:11 +00:00
|
|
|
# This is a Solaris-specific test to modify the PATH so that
|
|
|
|
# Posix-conformant tools are used by default.
|
|
|
|
|
2006-08-01 00:57:36 +00:00
|
|
|
if test -d /usr/xpg4/bin
|
|
|
|
if not contains /usr/xpg4/bin $PATH
|
|
|
|
set PATH /usr/xpg4/bin $PATH
|
2006-07-31 00:31:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-05-18 13:00:17 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Make sure there are no invalid entries in the PATH
|
|
|
|
#
|
|
|
|
|
2006-07-31 00:33:11 +00:00
|
|
|
if status --is-interactive
|
|
|
|
set -l erase_idx
|
|
|
|
for idx in (seq (count $PATH))
|
|
|
|
set i $PATH[$idx]
|
|
|
|
if not test -d $i
|
|
|
|
set erase_idx $erase_idx $idx
|
|
|
|
printf (_ '%s: Warning: The directory %s has been removed from your PATH because it does not exist\n') fish $i
|
|
|
|
end
|
|
|
|
end
|
2006-05-18 13:00:17 +00:00
|
|
|
|
2006-07-31 00:33:11 +00:00
|
|
|
if count $erase_idx >/dev/null
|
|
|
|
set -e PATH[(echo $erase_idx)]
|
|
|
|
end
|
2006-05-18 13:00:17 +00:00
|
|
|
end
|
|
|
|
|
2006-03-13 19:07:24 +00:00
|
|
|
#
|
|
|
|
# Add a few common directories to path, if they exists. Note that pure
|
|
|
|
# console programs like makedep sometimes live in /usr/X11R6/bin, so we
|
|
|
|
# want this even for text-only terminals.
|
|
|
|
#
|
|
|
|
|
2006-07-23 17:04:02 +00:00
|
|
|
set -l path_list /bin /usr/bin /usr/X11R6/bin @prefix@/bin @optbindirs@
|
2006-03-13 19:07:24 +00:00
|
|
|
|
|
|
|
# Root should also have the sbin directories in the path
|
|
|
|
if test "$USER" = root
|
|
|
|
set path_list $path_list /sbin /usr/sbin /usr/local/sbin
|
|
|
|
end
|
|
|
|
|
2006-05-30 09:14:17 +00:00
|
|
|
# Make a regular expression that matches any component in the PATH. A
|
2006-08-01 00:52:46 +00:00
|
|
|
# trailing slash is ok. The sed call is to remove the last '|'.
|
2006-07-31 00:33:54 +00:00
|
|
|
set -l tmp (printf "%s" \^$PATH'/?$|')
|
|
|
|
set -l path_regexp \((echo $tmp | sed -e "s/.\$//")\)
|
2006-05-18 13:37:26 +00:00
|
|
|
|
2006-07-31 00:33:54 +00:00
|
|
|
for i in (printf "%s\n" $path_list|grep -E -v $path_regexp)
|
2006-05-18 13:37:26 +00:00
|
|
|
if test -d $i
|
|
|
|
set PATH $PATH $i
|
2006-03-13 19:07:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-10-09 21:49:05 +00:00
|
|
|
#
|
|
|
|
# Print a greeting
|
|
|
|
#
|
|
|
|
|
|
|
|
if not set -q fish_greeting
|
|
|
|
set -l line1 (printf (_ 'Welcome to fish, the friendly interactive shell') )
|
|
|
|
set -l line2 (printf (_ 'Type %shelp%s for instructions on how to use fish') (set_color green) (set_color normal))
|
|
|
|
set -U fish_greeting $line1\n$line2
|
|
|
|
end
|
|
|
|
|
2006-10-10 17:31:54 +00:00
|
|
|
if status --is-interactive
|
|
|
|
echo $fish_greeting
|
|
|
|
end
|
2006-10-09 21:49:05 +00:00
|
|
|
|
2006-02-21 15:37:01 +00:00
|
|
|
#
|
|
|
|
# Don't need completions in non-interactive mode
|
|
|
|
#
|
|
|
|
|
2005-09-20 13:31:55 +00:00
|
|
|
if not status --is-interactive
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Convenience functions
|
|
|
|
#
|
|
|
|
# The naming heuristic is that __fish_complete_* prints completions
|
2006-04-21 15:05:58 +00:00
|
|
|
# and descriptions, while __fish_print_* only prints the completions
|
|
|
|
# and no descriptions
|
2005-09-20 13:31:55 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
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-07-31 00:33:54 +00:00
|
|
|
for i in (builtin -n|grep -E -v '(while|for|if|function|switch)' )
|
2006-03-10 13:43:50 +00:00
|
|
|
complete -c $i -s h -l help -d "Display help and exit"
|
2005-09-20 13:31:55 +00:00
|
|
|
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
|
|
|
|