From 60e3a4abaafd3eadc612e3b6e07b6db6cc79c1dc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 10 Dec 2019 14:51:47 -0500 Subject: [PATCH] zsh: reduce config if TERM == dumb Fixes TRAMP hangs when connecting to some machines --- config/zsh/.zshrc | 74 ++++++++++++++++++++++--------------------- config/zsh/config.zsh | 9 ++++-- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index 2d1f14a9..085ff8ad 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -16,44 +16,46 @@ if ! zgen saved; then zgen save fi -source $ZDOTDIR/prompt.zsh source $ZDOTDIR/config.zsh -source $ZDOTDIR/keybinds.zsh -source $ZDOTDIR/completion.zsh -source $ZDOTDIR/aliases.zsh -for file in $XDG_CONFIG_HOME/zsh/rc.d/aliases.*.zsh(N); do - source $file -done +if [[ $TERM != dumb ]]; then + source $ZDOTDIR/prompt.zsh + source $ZDOTDIR/keybinds.zsh + source $ZDOTDIR/completion.zsh + source $ZDOTDIR/aliases.zsh + for file in $XDG_CONFIG_HOME/zsh/rc.d/aliases.*.zsh(N); do + source $file + done -## -function _cache { - command -v "$1" >/dev/null || return 1 - local cache_dir="$XDG_CACHE_HOME/${SHELL##*/}" - local cache="$cache_dir/$1" - if [[ ! -f $cache || ! -s $cache ]]; then - echo "Caching $1" - mkdir -p $cache_dir - "$@" >$cache + ## + function _cache { + command -v "$1" >/dev/null || return 1 + local cache_dir="$XDG_CACHE_HOME/${SHELL##*/}" + local cache="$cache_dir/$1" + if [[ ! -f $cache || ! -s $cache ]]; then + echo "Caching $1" + mkdir -p $cache_dir + "$@" >$cache + fi + source $cache || rm -f $cache + } + + # fd > find + if command -v fd >/dev/null; then + export FZF_DEFAULT_OPTS="--reverse --ansi" + export FZF_DEFAULT_COMMAND="fd ." + export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" + export FZF_ALT_C_COMMAND="fd -t d . $HOME" fi - source $cache || rm -f $cache -} -# fd > find -if command -v fd >/dev/null; then - export FZF_DEFAULT_OPTS="--reverse --ansi" - export FZF_DEFAULT_COMMAND="fd ." - export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" - export FZF_ALT_C_COMMAND="fd -t d . $HOME" + _cache fasd --init posix-alias zsh-{hook,{c,w}comp{,-install}} + _cache direnv hook zsh + + + ## + autoload -Uz compinit && compinit -u -d $ZSH_CACHE/zcompdump + autopair-init + + + # If you have host-local configuration, this is where you'd put it + [ -f ~/.config/zsh/rc ] && source ~/.config/zsh/rc fi - -_cache fasd --init posix-alias zsh-{hook,{c,w}comp{,-install}} -_cache direnv hook zsh - - -## -autoload -Uz compinit && compinit -u -d $ZSH_CACHE/zcompdump -autopair-init - - -# If you have host-local configuration, this is where you'd put it -[ -f ~/.config/zsh/rc ] && source ~/.config/zsh/rc diff --git a/config/zsh/config.zsh b/config/zsh/config.zsh index 79ab8f1d..a34771e6 100644 --- a/config/zsh/config.zsh +++ b/config/zsh/config.zsh @@ -1,6 +1,11 @@ -# Stop term/shell echoing back my input -if [[ -n $INSIDE_EMACS ]]; then +# Stop TRAMP (in Emacs) from hanging or term/shell from echoing back commands +if [[ $TERM == dumb || -n $INSIDE_EMACS ]]; then unsetopt zle + unsetopt prompt_cr + unsetopt prompt_subst + whence -w precmd >/dev/null && unfunction precmd + whence -w preexec >/dev/null && unfunction preexec + PS1='$ ' fi ## General