From da4a4bcc186e14451ad39f07f6a05eda27a4007f Mon Sep 17 00:00:00 2001 From: liljencrantz Date: Wed, 9 Jan 2008 02:18:56 +1000 Subject: [PATCH] Only set various startup defaults once. Even if the user removes them, do not try to reset them. darcs-hash:20080108161856-75c98-7d228f7a0c62aa8be74f66ce72d0cadbc3030f5d.gz --- .../functions/__fish_config_interactive.fish | 122 +++++++++--------- 1 file changed, 62 insertions(+), 60 deletions(-) diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index e4003a1a3..469047e2a 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -74,12 +74,9 @@ function __fish_config_interactive -d "Initializations that should be performed end # - # Print a greeting - # - - # - # If we are starting up for the first time, set the default greeting + # If we are starting up for the first time, set various defaults # + if not set -q __fish_init_1_23_0 if not set -q fish_greeting set -l line1 (printf (_ 'Welcome to fish, the friendly interactive shell') ) @@ -87,8 +84,68 @@ function __fish_config_interactive -d "Initializations that should be performed set -U fish_greeting $line1\n$line2 end set -U __fish_init_1_23_0 + + # + # Set various defaults using these throwaway functions + # + + function set_default -d "Set a universal variable, unless it has already been set" + if not set -q $argv[1] + set -U -- $argv + end + end + + # Regular syntax highlighting colors + set_default fish_color_normal normal + set_default fish_color_command green + set_default fish_color_redirection normal + set_default fish_color_comment red + set_default fish_color_error red --bold + set_default fish_color_escape cyan + set_default fish_color_operator cyan + set_default fish_color_quote brown + set_default fish_color_valid_path --underline + + set_default fish_color_cwd green + set_default fish_color_cwd_root red + + # Background color for matching quotes and parenthesis + set_default fish_color_match cyan + + # Background color for search matches + set_default fish_color_search_match purple + + # Pager colors + set_default fish_pager_color_prefix cyan + set_default fish_pager_color_completion normal + set_default fish_pager_color_description normal + set_default fish_pager_color_progress cyan + + # + # Directory history colors + # + + set_default fish_color_history_current cyan + + + # + # Setup the CDPATH variable + # + + set_default CDPATH . ~ + + # + # Remove temporary functions for setting default variable values + # + + functions -e set_default + end + # + # Print a greeting + # + switch $fish_greeting case '' # If variable is empty, don't print anything, saves us a fork @@ -105,61 +162,6 @@ function __fish_config_interactive -d "Initializations that should be performed printf (_ "Good bye\n") end - # - # Set various defaults using these throwaway functions - # - - function set_default -d "Set a universal variable, unless it has already been set" - if not set -q $argv[1] - set -U -- $argv - end - end - - # Regular syntax highlighting colors - set_default fish_color_normal normal - set_default fish_color_command green - set_default fish_color_redirection normal - set_default fish_color_comment red - set_default fish_color_error red --bold - set_default fish_color_escape cyan - set_default fish_color_operator cyan - set_default fish_color_quote brown - set_default fish_color_valid_path --underline - - set_default fish_color_cwd green - set_default fish_color_cwd_root red - - # Background color for matching quotes and parenthesis - set_default fish_color_match cyan - - # Background color for search matches - set_default fish_color_search_match purple - - # Pager colors - set_default fish_pager_color_prefix cyan - set_default fish_pager_color_completion normal - set_default fish_pager_color_description normal - set_default fish_pager_color_progress cyan - - # - # Directory history colors - # - - set_default fish_color_history_current cyan - - - # - # Setup the CDPATH variable - # - - set_default CDPATH . ~ - - # - # Remove temporary functions for setting default variable values - # - - functions -e set_default - # # This event handler makes sure the prompt is repainted when # fish_color_cwd changes value. Like all event handlers, it can't be