From 602d2931b1cd78bbfb75a4e1fd8de7e6a8553689 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Mon, 22 Apr 2019 17:38:33 +0200 Subject: [PATCH] Fix handling of legacy terminal types Disable plugins/code requiring current terminal features not only on "dumb" terminals, but on legacy ("not modern") terminals, too. This is handled by using the axzsh_is_modern_terminal() function insetad of axzsh_is_dumb_terminal(). And fix plugins to return 91 ("ignore") as result code in this case. In addition, disable theming only on dumb terminals (as before), but fall back to the standard "ax" theme on non-modern terminals, too! --- ax.zsh | 18 +++++++++--------- core/11_terminal/11_terminal.zshrc | 9 +++++++-- core/90_theme/90_theme.zshrc | 16 +++++++++++----- plugins/fzf/fzf.zshrc | 2 ++ plugins/iterm2/iterm2.zshrc | 2 +- plugins/powerline-shell/powerline-shell.zshrc | 2 +- .../zsh-autosuggestions.zshrc | 2 +- .../zsh-syntax-highlighting.zshrc | 2 +- 8 files changed, 33 insertions(+), 20 deletions(-) diff --git a/ax.zsh b/ax.zsh index d7f8098..1936327 100644 --- a/ax.zsh +++ b/ax.zsh @@ -77,17 +77,17 @@ function axzsh_load_plugin { [[ -n "$AXZSH_DEBUG" ]] \ && echo " - $plugin ($type) ..." - # Note for "external" ("repo/*") plugins and "dumb" terminals: - # These (modern?) plugins most probably don't expect such an - # unusual old terminal configuration and don't behave well - # (echo color sequences, for example). Therefore we DON'T load - # any external plugins at all when running on such a terminal: - # this results in reduced/disabled functionality, but hopefully - # in readable output ... + # Note for "external" ("repo/*") plugins and unusual ("not so + # modern") terminals: These (modern?) plugins most probably + # don't expect such a terminal configuration and don't behave + # well (echo color sequences, for example). Therefore we DON'T + # load any external plugins at all in that case: this results in + # reduced/disabled functionality, but hopefully in readable + # output ... case "$fname" in *"/repos/"*) - axzsh_is_dumb_terminal || source "$fname" + axzsh_is_modern_terminal && source "$fname" ;; *) source "$fname" @@ -99,7 +99,7 @@ function axzsh_load_plugin { case "$fname" in *"/repos/"*) echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo ' - $plugin ($type): \"$fname\" ...'" >>$cache_file - echo "axzsh_is_dumb_terminal || source '$fname'" >>$cache_file + echo "axzsh_is_modern_terminal && source '$fname'" >>$cache_file ;; *) echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo ' - $plugin ($type, cached) ...'" >>$cache_file diff --git a/core/11_terminal/11_terminal.zshrc b/core/11_terminal/11_terminal.zshrc index 2da958b..5e23066 100644 --- a/core/11_terminal/11_terminal.zshrc +++ b/core/11_terminal/11_terminal.zshrc @@ -139,8 +139,13 @@ axzsh_is_dumb_terminal && return 0 autoload -Uz colors colors -fg[default]="\e[39m" -bg[default]="\e[49m" +if axzsh_is_modern_terminal; then + fg[default]="\e[39m" + bg[default]="\e[49m" +else + fg[default]="\e[37m" + bg[default]="\e[47m" +fi # Foreground (FG) and background (BG) colors. typeset -Ag FG BG diff --git a/core/90_theme/90_theme.zshrc b/core/90_theme/90_theme.zshrc index 140c73a..7fb4301 100644 --- a/core/90_theme/90_theme.zshrc +++ b/core/90_theme/90_theme.zshrc @@ -4,12 +4,18 @@ # Don't load any "enhanced" theme on dumb terminals, but instead use a very # simple and sane built-in prompt that should work "everywhere". And try to # make sure that nothing else "disturbs" such terminals ... -if axzsh_is_dumb_terminal; then - unset AXZSH_THEME +if ! axzsh_is_modern_terminal; then + if axzsh_is_dumb_terminal; then + # Don't use any theme on dumb terminals! + unset AXZSH_THEME - # Set simple prompt: - PS1="%n@%m:%3~ %# " - unset RPS1 + # Set simple prompt: + PS1="%n@%m:%3~ %# " + unset RPS1 + else + # Use the default theme on legacy ("not modern") terminals: + AXZSH_THEME="$AXZSH/themes/ax.axzshtheme" + fi # See unset zle_bracketed_paste diff --git a/plugins/fzf/fzf.zshrc b/plugins/fzf/fzf.zshrc index bbc1cfa..4e46e9f 100644 --- a/plugins/fzf/fzf.zshrc +++ b/plugins/fzf/fzf.zshrc @@ -1,6 +1,8 @@ # AX-ZSH: Alex' Modular ZSH Configuration # fzf.zshrc: Setup Git +axzsh_is_modern_terminal || return 91 + # Test for local fzf installation ... if [[ -r ~/.fzf.zsh ]]; then source ~/.fzf.zsh diff --git a/plugins/iterm2/iterm2.zshrc b/plugins/iterm2/iterm2.zshrc index dc24d79..6ee03e3 100644 --- a/plugins/iterm2/iterm2.zshrc +++ b/plugins/iterm2/iterm2.zshrc @@ -4,7 +4,7 @@ [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 # Check prerequisites ... -axzsh_is_dumb_terminal && return 91 +axzsh_is_modern_terminal || return 91 [[ -o interactive ]] || return 91 [[ -z "$ITERM_SHELL_INTEGRATION_INSTALLED" ]] || return 91 [[ "$TERM" != "screen" && "$TERM" != "screen-256color" ]] || return 91 diff --git a/plugins/powerline-shell/powerline-shell.zshrc b/plugins/powerline-shell/powerline-shell.zshrc index 7a4873f..b57c467 100644 --- a/plugins/powerline-shell/powerline-shell.zshrc +++ b/plugins/powerline-shell/powerline-shell.zshrc @@ -1,7 +1,7 @@ # AX-ZSH: Alex' Modular ZSH Configuration # powerline-shell.zshrc: "powerline-shell" integration. -[[ "$TERM" = "linux" ]] && return 911 +axzsh_is_modern_terminal || return 91 if [[ -z "$POWERLINE_SHELL" ]]; then for p ( diff --git a/plugins/zsh-autosuggestions/zsh-autosuggestions.zshrc b/plugins/zsh-autosuggestions/zsh-autosuggestions.zshrc index 6492620..0a9457a 100644 --- a/plugins/zsh-autosuggestions/zsh-autosuggestions.zshrc +++ b/plugins/zsh-autosuggestions/zsh-autosuggestions.zshrc @@ -1,7 +1,7 @@ # AX-ZSH: Alex' Modular ZSH Configuration # zsh-autosuggestions.zshrc: Initialize "Fish-like autosuggestions for zsh" -axzsh_is_dumb_terminal && return 1 +axzsh_is_modern_terminal || return 91 for script ( "/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh" diff --git a/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zshrc b/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zshrc index cdc4ed9..6bf0953 100644 --- a/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zshrc +++ b/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zshrc @@ -1,7 +1,7 @@ # AX-ZSH: Alex' Modular ZSH Configuration # zsh-syntax-highlighting.zshrc: Initialize "ZSH Syntax Highlighting" -axzsh_is_dumb_terminal && return 1 +axzsh_is_modern_terminal || return 91 for script ( "/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" -- 2.39.2