]> arthur.barton.de Git - ax-zsh.git/commitdiff
Fix handling of legacy terminal types
authorAlexander Barton <alex@barton.de>
Mon, 22 Apr 2019 15:38:33 +0000 (17:38 +0200)
committerAlexander Barton <alex@barton.de>
Mon, 22 Apr 2019 15:38:33 +0000 (17:38 +0200)
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
core/11_terminal/11_terminal.zshrc
core/90_theme/90_theme.zshrc
plugins/fzf/fzf.zshrc
plugins/iterm2/iterm2.zshrc
plugins/powerline-shell/powerline-shell.zshrc
plugins/zsh-autosuggestions/zsh-autosuggestions.zshrc
plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zshrc

diff --git a/ax.zsh b/ax.zsh
index d7f80981a51e316e522365c5eb52ab7da1835232..1936327986e8e241bea0880b6e06ab20447c4c9a 100644 (file)
--- 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
index 2da958b1e7feb4a5db589cf8d701bb3f9bb4fda4..5e2306694fed1f45a6086fb3898cff0f72b41d6c 100644 (file)
@@ -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
index 140c73aa968d7fbd398897c6e9cbdb0c97713dbf..7fb4301287afbc74a0a94755b38d23e5f6eba832 100644 (file)
@@ -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 <https://github.com/syl20bnr/spacemacs/issues/3035>
        unset zle_bracketed_paste
index bbc1cfa55bf18a2b35c097463e211cb7be1f7e59..4e46e9f5cc16b92bfaeb14d24ef6cb4e629b1de6 100644 (file)
@@ -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
index dc24d79ba63cbb1a44f92e6bbd6ee92a5dcb0906..6ee03e3826afeaa8b546f4f7b9d0951cbaee4e9c 100644 (file)
@@ -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
index 7a4873f77589c3a91dfb8d0d984a5f6cf70185af..b57c467e5b1a4df11637ef587f9dfc412939c9d0 100644 (file)
@@ -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 (
index 6492620ec11c6ab70fde7302224227a105b9a102..0a9457a6fb682d74b15b851a5123a6b18c771d5b 100644 (file)
@@ -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"
index cdc4ed9fc2061431d2a6776dcb15d026f299638f..6bf09533a80c266ef17c9d4ad9aa231aca683c11 100644 (file)
@@ -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"