aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_config_interactive.fish
diff options
context:
space:
mode:
Diffstat (limited to 'share/functions/__fish_config_interactive.fish')
-rw-r--r--share/functions/__fish_config_interactive.fish156
1 files changed, 82 insertions, 74 deletions
diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish
index d9ee0700..ea71a72a 100644
--- a/share/functions/__fish_config_interactive.fish
+++ b/share/functions/__fish_config_interactive.fish
@@ -19,58 +19,10 @@ function __fish_config_interactive -d "Initializations that should be performed
if set -q XDG_CONFIG_HOME
set configdir $XDG_CONFIG_HOME
end
-
- # Migrate old (pre 1.22.0) init scripts if they exist
- if not set -q __fish_init_1_22_0
-
- if test -f ~/.fish_history -o -f ~/.fish -o -d ~/.fish.d -a ! -d $configdir/fish
-
- # Perform upgrade of configuration file hierarchy
-
- if not test -d $configdir
- command mkdir $configdir >/dev/null
- end
-
- if test -d $configdir
- if command mkdir $configdir/fish
-
- # These files are sometimes overwritten to by fish, so
- # we want backups of them in case something goes wrong
-
- cp ~/.fishd.(hostname) $configdir/fish/fishd.(hostname).backup
- cp ~/.fish_history $configdir/fish/fish_history.backup
-
- # Move the files
-
- mv ~/.fish_history $configdir/fish/fish_history
- mv ~/.fish $configdir/fish/config.fish
- mv ~/.fish_inputrc $configdir/fish/fish_inputrc
- mv ~/.fish.d/functions $configdir/fish/functions
- mv ~/.fish.d/completions $configdir/fish/completions
-
- #
- # Move the fishd stuff from another shell to avoid concurrency problems
- #
-
- /bin/sh -c mv\ \~/.fishd.(hostname)\ $configdir/fish/fishd.(hostname)\;kill\ -9\ (echo %fishd)
-
- # Update paths to point to new configuration locations
-
- set fish_function_path (printf "%s\n" $fish_function_path|sed -e "s|/usr/local/etc/fish.d/|/usr/local/etc/fish/|")
- set fish_complete_path (printf "%s\n" $fish_complete_path|sed -e "s|/usr/local/etc/fish.d/|/usr/local/etc/fish/|")
-
- set fish_function_path (printf "%s\n" $fish_function_path|sed -e "s|$HOME/.fish.d/|$configdir/fish/|")
- set fish_complete_path (printf "%s\n" $fish_complete_path|sed -e "s|$HOME/.fish.d/|$configdir/fish/|")
-
- printf (_ "\nWARNING\n\nThe location for fish configuration files has changed to %s.\nYour old files have been moved to this location.\nYou can change to a different location by changing the value of the variable \$XDG_CONFIG_HOME.\n\n") $configdir
-
- end ^/dev/null
- end
- end
-
- # Make sure this is only done once
- set -U __fish_init_1_22_0
-
+ # Set the correct user data directory
+ set -l userdatadir ~/.local/share
+ if set -q XDG_DATA_HOME
+ set userdatadir $XDG_DATA_HOME
end
#
@@ -117,6 +69,9 @@ function __fish_config_interactive -d "Initializations that should be performed
# Background color for search matches
set_default fish_color_search_match --background=purple
+ # Background color for selections
+ set_default fish_color_selection --background=purple
+
# Pager colors
set_default fish_pager_color_prefix cyan
set_default fish_pager_color_completion normal
@@ -137,20 +92,31 @@ function __fish_config_interactive -d "Initializations that should be performed
end
- #
- # Print a greeting
- #
+ #
+ # Generate man page completions if not present
+ #
- if functions -q fish_greeting
- fish_greeting
- else
- if set -q fish_greeting
- switch "$fish_greeting"
- case ''
- # If variable is empty, don't print anything, saves us a fork
+ if not test -d $userdatadir/fish/generated_completions
+ #fish_update_completions is a function, so it can not be directly run in background.
+ eval "$__fish_bin_dir/fish -c 'fish_update_completions > /dev/null ^/dev/null' &"
+ end
- case '*'
- echo $fish_greeting
+ if status -i
+ #
+ # Print a greeting
+ #
+
+ if functions -q fish_greeting
+ fish_greeting
+ else
+ if set -q fish_greeting
+ switch "$fish_greeting"
+ case ''
+ # If variable is empty, don't print anything, saves us a fork
+
+ case '*'
+ echo $fish_greeting
+ end
end
end
end
@@ -193,10 +159,17 @@ function __fish_config_interactive -d "Initializations that should be performed
# Reload key bindings when binding variable change
function __fish_reload_key_bindings -d "Reload key bindings when binding variable change" --on-variable fish_key_bindings
- # Do something nasty to avoid two forks
+ # do nothing if the key bindings didn't actually change
+ # This could be because the variable was set to the existing value
+ # or because it was a local variable
+ if test "$fish_key_bindings" = "$__fish_active_key_bindings"
+ return
+ end
+ set -g __fish_active_key_bindings "$fish_key_bindings"
+ set -g fish_bind_mode default
if test "$fish_key_bindings" = fish_default_key_bindings
fish_default_key_bindings
- #Load user key bindings if they are defined
+ # Load user key bindings if they are defined
if functions --query fish_user_key_bindings > /dev/null
fish_user_key_bindings
end
@@ -205,8 +178,9 @@ function __fish_config_interactive -d "Initializations that should be performed
end
end
- # Load key bindings
- __fish_reload_key_bindings
+ # Load key bindings. Redirect stderr per #1155
+ set -g __fish_active_key_bindings
+ __fish_reload_key_bindings ^ /dev/null
# Repaint screen when window changes size
function __fish_winch_handler --on-signal winch
@@ -215,33 +189,67 @@ function __fish_config_interactive -d "Initializations that should be performed
# Notify vte-based terminals when $PWD changes (issue #906)
- if test "$VTE_VERSION" -ge 3405
+ if test "$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal"
function __update_vte_cwd --on-variable PWD --description 'Notify VTE of change to $PWD'
status --is-command-substitution; and return
- printf '\033]7;file://%s\a' (pwd | __fish_urlencode)
+ printf '\033]7;file://%s%s\a' (hostname) (pwd | __fish_urlencode)
end
end
# The first time a command is not found, look for command-not-found
# This is not cheap so we try to avoid doing it during startup
+ # config.fish already installed a handler for noninteractive command-not-found,
+ # so delete it here since we are now interactive
+ functions -e __fish_command_not_found_handler
+
+ # Now install our fancy variant
function __fish_command_not_found_setup --on-event fish_command_not_found
# Remove fish_command_not_found_setup so we only execute this once
functions --erase __fish_command_not_found_setup
- # First check in /usr/lib, this is where modern Ubuntus place this command
- if test -f /usr/lib/command-not-found
+ # First check if we are on OpenSUSE since SUSE's handler has no options
+ # and expects first argument to be a command and second database
+ # also check if there is command-not-found command.
+ if begin; test -f /etc/SuSE-release; and type -q -p command-not-found; end
+ function __fish_command_not_found_handler --on-event fish_command_not_found
+ /usr/bin/command-not-found $argv
+ end
+ # Check for Fedora's handler
+ else if test -f /usr/libexec/pk-command-not-found
+ function __fish_command_not_found_handler --on-event fish_command_not_found
+ /usr/libexec/pk-command-not-found $argv
+ end
+ # Check in /usr/lib, this is where modern Ubuntus place this command
+ else if test -f /usr/lib/command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/lib/command-not-found -- $argv
end
+ # Check for NixOS handler
+ else if test -f /run/current-system/sw/bin/command-not-found
+ function __fish_command_not_found_handler --on-event fish_command_not_found
+ /run/current-system/sw/bin/command-not-found $argv
+ end
# Ubuntu Feisty places this command in the regular path instead
- else if type -p command-not-found > /dev/null 2> /dev/null
+ else if type -q -p command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
command-not-found -- $argv
end
+ # pkgfile is an optional, but official, package on Arch Linux
+ # it ships with example handlers for bash and zsh, so we'll follow that format
+ else if type -p -q pkgfile
+ function __fish_command_not_found_handler --on-event fish_command_not_found
+ set -l __packages (pkgfile --binaries --verbose -- $argv ^/dev/null)
+ if test $status -eq 0
+ printf "%s may be found in the following packages:\n" "$argv"
+ printf " %s\n" $__packages
+ else
+ __fish_default_command_not_found_handler $argv
+ end
+ end
# Use standard fish command not found handler otherwise
else
function __fish_command_not_found_handler --on-event fish_command_not_found
- echo fish: Unknown command "'$argv'" >&2
+ __fish_default_command_not_found_handler $argv
end
end
__fish_command_not_found_handler $argv