2006-10-19 11:50:23 +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.
|
|
|
|
#
|
|
|
|
|
2007-04-22 18:49:56 +00:00
|
|
|
#
|
|
|
|
# Set default field separators
|
|
|
|
#
|
|
|
|
|
|
|
|
set -g IFS \n\ \t
|
|
|
|
|
2006-10-19 11:50:23 +00:00
|
|
|
#
|
|
|
|
# Set default search paths for completions and shellscript functions
|
|
|
|
# unless they already exist
|
|
|
|
#
|
|
|
|
|
|
|
|
set -l configdir ~/.config
|
2007-10-28 09:08:40 +00:00
|
|
|
|
2006-10-19 11:50:23 +00:00
|
|
|
if set -q XDG_CONFIG_HOME
|
|
|
|
set configdir $XDG_CONFIG_HOME
|
|
|
|
end
|
|
|
|
|
2012-07-08 22:20:39 +00:00
|
|
|
# __fish_datadir, __fish_sysconfdir, __fish_help_dir, __fish_bin_dir
|
|
|
|
# are expected to have been set up by read_init from fish.cpp
|
2006-10-19 11:50:23 +00:00
|
|
|
|
2007-10-28 09:08:40 +00:00
|
|
|
# Set up function and completion paths. Make sure that the fish
|
|
|
|
# default functions/completions are included in the respective path.
|
|
|
|
|
2010-09-18 02:18:26 +00:00
|
|
|
if not set -q fish_function_path
|
2012-07-08 22:20:39 +00:00
|
|
|
set fish_function_path $configdir/fish/functions $__fish_sysconfdir/functions $__fish_datadir/functions
|
2006-10-19 11:50:23 +00:00
|
|
|
end
|
|
|
|
|
2012-07-08 22:20:39 +00:00
|
|
|
if not contains $__fish_datadir/functions $fish_function_path
|
|
|
|
set fish_function_path[-1] $__fish_datadir/functions
|
2007-10-28 09:10:42 +00:00
|
|
|
end
|
|
|
|
|
2010-09-18 02:18:26 +00:00
|
|
|
if not set -q fish_complete_path
|
2013-02-18 00:14:36 +00:00
|
|
|
set fish_complete_path $configdir/fish/completions $__fish_sysconfdir/completions $__fish_datadir/completions $configdir/fish/generated_completions
|
2006-10-19 11:50:23 +00:00
|
|
|
end
|
|
|
|
|
2012-07-08 22:20:39 +00:00
|
|
|
if not contains $__fish_datadir/completions $fish_complete_path
|
|
|
|
set fish_complete_path[-1] $__fish_datadir/completions
|
2007-10-28 09:10:42 +00:00
|
|
|
end
|
|
|
|
|
2007-10-28 09:08:40 +00:00
|
|
|
#
|
2006-10-19 11:50:23 +00:00
|
|
|
# This is a Solaris-specific test to modify the PATH so that
|
2007-10-28 09:08:40 +00:00
|
|
|
# Posix-conformant tools are used by default. It is separate from the
|
|
|
|
# other PATH code because this directory needs to be prepended, not
|
|
|
|
# appended, since it contains POSIX-compliant replacements for various
|
|
|
|
# system utilities.
|
|
|
|
#
|
2006-10-19 11:50:23 +00:00
|
|
|
|
|
|
|
if test -d /usr/xpg4/bin
|
|
|
|
if not contains /usr/xpg4/bin $PATH
|
2010-09-18 02:18:26 +00:00
|
|
|
set PATH /usr/xpg4/bin $PATH
|
2006-10-19 11:50:23 +00:00
|
|
|
end
|
2010-09-18 02:18:26 +00:00
|
|
|
end
|
2006-10-19 11:50:23 +00:00
|
|
|
|
2013-02-20 01:48:51 +00:00
|
|
|
# Add a handler for when fish_user_path changes, so we can apply the same changes to PATH
|
|
|
|
# Invoke it immediately to apply the current value of fish_user_path
|
|
|
|
function __fish_reconstruct_path -d "Update PATH when fish_user_paths changes" --on-variable fish_user_paths
|
|
|
|
set -l local_path $PATH
|
|
|
|
set -l x
|
|
|
|
for x in $__fish_added_user_paths
|
|
|
|
if set -l idx (contains --index $x $local_path)
|
|
|
|
set -e local_path[$idx]
|
|
|
|
end
|
2006-10-19 11:50:23 +00:00
|
|
|
end
|
|
|
|
|
2013-02-20 01:48:51 +00:00
|
|
|
set -e __fish_added_user_paths
|
2013-06-22 15:15:43 +00:00
|
|
|
for x in $fish_user_paths[-1..1]
|
2013-02-20 01:48:51 +00:00
|
|
|
if not contains $x $local_path
|
2013-06-22 15:15:43 +00:00
|
|
|
set local_path $x $local_path
|
2013-02-20 01:48:51 +00:00
|
|
|
set -g __fish_added_user_paths $__fish_added_user_paths $x
|
|
|
|
end
|
|
|
|
end
|
|
|
|
set -xg PATH $local_path
|
|
|
|
end
|
|
|
|
__fish_reconstruct_path
|
2013-02-02 01:18:12 +00:00
|
|
|
|
2013-02-22 22:01:17 +00:00
|
|
|
# OS X-ism: Load the path files out of /etc/paths and /etc/paths.d/*
|
|
|
|
function __fish_load_path_helper_paths
|
|
|
|
while read -l new_path_comp
|
|
|
|
if not contains $new_path_comp $PATH
|
|
|
|
set PATH $PATH $new_path_comp
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if test -r /etc/paths ; __fish_load_path_helper_paths < /etc/paths ; end
|
|
|
|
for pathfile in /etc/paths.d/* ; __fish_load_path_helper_paths < $pathfile ; end
|
|
|
|
functions -e __fish_load_path_helper_paths
|
|
|
|
|
|
|
|
|
2007-08-19 16:42:30 +00:00
|
|
|
#
|
2007-04-23 21:10:26 +00:00
|
|
|
# Launch debugger on SIGTRAP
|
2007-08-19 16:42:30 +00:00
|
|
|
#
|
2013-02-20 01:48:51 +00:00
|
|
|
function fish_sigtrap_handler --on-signal TRAP --no-scope-shadowing --description "Signal handler for the TRAP signal. Launches a debug prompt."
|
2007-04-23 21:10:26 +00:00
|
|
|
breakpoint
|
|
|
|
end
|
2006-10-19 11:50:23 +00:00
|
|
|
|
2007-08-19 16:42:30 +00:00
|
|
|
#
|
|
|
|
# Whenever a prompt is displayed, make sure that interactive
|
|
|
|
# mode-specific initializations have been performed.
|
2007-10-28 09:11:17 +00:00
|
|
|
# This handler removes itself after it is first called.
|
2007-08-19 16:42:30 +00:00
|
|
|
#
|
|
|
|
function __fish_on_interactive --on-event fish_prompt
|
|
|
|
__fish_config_interactive
|
2007-10-28 09:11:17 +00:00
|
|
|
functions -e __fish_on_interactive
|
2006-10-19 11:50:23 +00:00
|
|
|
end
|
2007-08-19 16:42:30 +00:00
|
|
|
|