]> arthur.barton.de Git - ax-zsh.git/commitdiff
Don't load themes and ext. plugins on "dumb" terminals
authorAlexander Barton <alex@barton.de>
Mon, 20 Nov 2017 23:28:47 +0000 (00:28 +0100)
committerAlexander Barton <alex@barton.de>
Mon, 20 Nov 2017 23:29:11 +0000 (00:29 +0100)
These external (and 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 ...

And the same is true for any themes, included or external: we disable
them and fallback to an included very simple but sane default prompt.

ax.zsh
core/90_theme/90_theme.zshrc

diff --git a/ax.zsh b/ax.zsh
index c5ffeab120dd739f790d565978176188231c0a75..0071767967b2a04e6a8f363b2c1d437cb48e7468 100644 (file)
--- a/ax.zsh
+++ b/ax.zsh
@@ -70,7 +70,22 @@ function axzsh_load_plugin {
                # Read plugin ...
                [[ -n "$AXZSH_DEBUG" ]] \
                        && echo "   - $plugin ($type) ..."
-               source "$fname"
+
+               # 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 ...
+
+               case "$fname" in
+                       *"/repos/"*)
+                               axzsh_is_dumb_terminal || source "$fname"
+                               ;;
+                       *)
+                               source "$fname"
+               esac
 
                if [[ -n "$cache_file" ]]; then
                        # Add plugin data to cache
@@ -78,7 +93,7 @@ function axzsh_load_plugin {
                        case "$fname" in
                                *"/repos/"*)
                                        echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo '     - $plugin ($type): \"$fname\" ...'" >>$cache_file
-                                       echo "source '$fname'" >>$cache_file
+                                       echo "axzsh_is_dumb_terminal || source '$fname'" >>$cache_file
                                        ;;
                                *)
                                        echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo '     - $plugin ($type, cached) ...'" >>$cache_file
index 084d2f3a3290a15a4a3624a20dd0b48095a49033..4c508fba672401bb7f914049f1ad99664ab5f356 100644 (file)
@@ -1,8 +1,18 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # 90_theme.zshrc: Load AX-ZSH theme
 
+# 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
+       PS1="%n@%m:%3~ %# "
+       unset RPS1
+
+       # See <https://github.com/syl20bnr/spacemacs/issues/3035>
+       unset zle_bracketed_paste
+
+       return
+fi
+
 # Read in the theme configuration.
 [[ -n "$AXZSH_THEME" ]] && source "$AXZSH_THEME"
-
-# RPS1 will cause trouble on "dumb" terminals; so reset it there!
-axzsh_is_dumb_terminal && unset RPS1