diff --git a/share/config.fish b/share/config.fish index 35de799b2..60fd0ba16 100644 --- a/share/config.fish +++ b/share/config.fish @@ -18,17 +18,33 @@ function __fish_default_command_not_found_handler end if status --is-interactive - # Enable truecolor/24-bit support for select terminals - if not set -q NVIM_LISTEN_ADDRESS # Neovim will swallow the 24bit sequences, rendering text white - and begin - set -q KONSOLE_PROFILE_NAME # KDE's konsole - or string match -q -- "*:*" $ITERM_SESSION_ID # Supporting versions of iTerm2 will include a colon here - or string match -q -- "st-*" $TERM # suckless' st - or test "$VTE_VERSION" -ge 3600 # Should be all gtk3-vte-based terms after version 3.6.0.0 - or test "$COLORTERM" = truecolor -o "$COLORTERM" = 24bit # slang expects this + # Existance of string is a good pre-2.3.0 check. Could also check $FISH_VERSION in the future. + # This is a "launch", not an issue caused by autoloading during upgrades. + if not contains "string" (builtin -n) + # the string.fish message to `exec` will probably not help here, so this will that. + set -g __is_launched_without_string 1 + + set_color --bold + echo "You appear to be trying to launch an old fish binary with newer scripts " + echo "installed into" (set_color --underline)"$__fish_datadir" + set_color normal + echo -e "\nThis is an unsupported configuration.\n" + set_color yellow + echo "You may need to uninstall and reinstall fish!" + set_color normal + else + # Enable truecolor/24-bit support for select terminals + if not set -q NVIM_LISTEN_ADDRESS # (Neovim will swallow the 24bit sequences, rendering text white) + and begin + set -q KONSOLE_PROFILE_NAME # KDE's konsole + or string match -q -- "*:*" $ITERM_SESSION_ID # Supporting versions of iTerm2 will include a colon here + or string match -q -- "st-*" $TERM # suckless' st + or test "$VTE_VERSION" -ge 3600 # Should be all gtk3-vte-based terms after version 3.6.0.0 + or test "$COLORTERM" = truecolor -o "$COLORTERM" = 24bit # slang expects this + end + # Only set it if it isn't to allow override by setting to 0 + set -q fish_term24bit; or set -g fish_term24bit 1 end - # Only set it if it isn't to allow override by setting to 0 - set -q fish_term24bit; or set -g fish_term24bit 1 end else # Hook up the default as the principal command_not_found handler diff --git a/share/functions/__fish_urlencode.fish b/share/functions/__fish_urlencode.fish index df07eee03..a879cb3e5 100644 --- a/share/functions/__fish_urlencode.fish +++ b/share/functions/__fish_urlencode.fish @@ -1,4 +1,8 @@ function __fish_urlencode --description "URL-encode stdin" + if not type -q string + return 1 + end + set -l join '' set -l chars # Set locale to C and IFS to "" in order to split a line into bytes. diff --git a/share/functions/prompt_pwd.fish b/share/functions/prompt_pwd.fish index 96e9b2f33..74372dd51 100644 --- a/share/functions/prompt_pwd.fish +++ b/share/functions/prompt_pwd.fish @@ -5,6 +5,12 @@ function prompt_pwd --description "Print the current working directory, shortene return 0 end + # If we don't have a string builtin, we have no hope of maniuplating $PWD - just output it as-is. + if not type -q string + echo $PWD + return 0 + end + # This allows overriding fish_prompt_pwd_dir_length from the outside (global or universal) without leaking it set -q fish_prompt_pwd_dir_length; or set -l fish_prompt_pwd_dir_length 1 diff --git a/share/functions/string.fish b/share/functions/string.fish new file mode 100644 index 000000000..bf76782df --- /dev/null +++ b/share/functions/string.fish @@ -0,0 +1,16 @@ +if not contains string (builtin -n) + function string + if not set -q __is_launched_without_string + if status --is-interactive + # We've been autoloaded after fish < 2.3.0 upgraded to >= 2.3.1 - no string builtin + set_color --bold + echo "Fish has been upgraded, and the scripts on your system are not compatible" + echo "with this prior instance of fish. You can probably run:" + set_color green + echo "\n exec fish" + set_color normal + echo "… to replace this process with a new one in-place." + end + end + end +end