From deab2ed37611056128cceb61daffaefc82c01331 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 27 Feb 2011 10:13:57 -0500 Subject: [PATCH] Fix for dumb terminals like Vim's. --- lib/completion.zsh | 1 + lib/grep.zsh | 10 ++++------ lib/misc.zsh | 4 ++-- lib/termsupport.zsh | 2 ++ lib/theme-and-appearance.zsh | 5 ++--- oh-my-zsh.sh | 5 +++++ templates/zshrc.zsh-template | 2 +- themes/sorin.zsh-theme | 6 +++--- 8 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index fdd0a853..9e770f18 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -1,4 +1,5 @@ # fixme - the load process here seems a bit bizarre +[[ "$TERM" == "dumb" ]] && return unsetopt menu_complete # do not autoselect the first completion entry unsetopt flowcontrol diff --git a/lib/grep.zsh b/lib/grep.zsh index 93c4270b..714ac9cc 100644 --- a/lib/grep.zsh +++ b/lib/grep.zsh @@ -1,6 +1,4 @@ -# -# Color grep results -# Examples: http://rubyurl.com/ZXv -# -export GREP_OPTIONS='--color=auto' -export GREP_COLOR='1;32' \ No newline at end of file +if [[ "$DISABLE_COLOR" != "true" ]]; then + [[ -z "$GREP_OPTIONS" ]] && export GREP_OPTIONS='--color=auto' + [[ -z "$GREP_COLOR" ]] && export GREP_COLOR='1;32' +fi diff --git a/lib/misc.zsh b/lib/misc.zsh index 4c174365..364ad879 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -9,5 +9,5 @@ bindkey "^[m" copy-prev-shell-word setopt long_list_jobs ## pager -export PAGER=less -export LC_CTYPE=en_US.UTF-8 +[[ -z "$PAGER" ]] && export PAGER=less +[[ -z "$LC_CTYPE" ]] && export LC_CTYPE=en_US.UTF-8 diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 22e7f372..9a576570 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -1,3 +1,5 @@ +[[ "$TERM" == "dumb" ]] && return + #usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title #http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 #Fully support screen, iterm, and probably most modern xterm and rxvt diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index aec67721..ab5aba4d 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -1,10 +1,9 @@ # ls colors autoload colors; colors; -export LSCOLORS="Gxfxcxdxbxegedabagacad" -#export LS_COLORS +[[ -z "$LSCOLORS" ]] && export LSCOLORS="Gxfxcxdxbxegedabagacad" # Enable ls colors -if [ "$DISABLE_LS_COLORS" != "true" ] +if [ "$DISABLE_COLOR" != "true" ] then # Find the option for using colors in ls, depending on the version: Linux or BSD ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c4522491..ddd1f043 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -6,6 +6,11 @@ fi # Initializes Oh My Zsh +# Disable colors on dumb terminals +if [ "$TERM" = "dumb" ]; then + DISABLE_COLOR="true" +fi + # add a function path fpath=($ZSH/functions $ZSH/completions $fpath) diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 576d45ea..65299df3 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -14,7 +14,7 @@ export ZSH_THEME="robbyrussell" # export DISABLE_AUTO_UPDATE="true" # Uncomment following line if you want to disable colors in ls -# export DISABLE_LS_COLORS="true" +# export DISABLE_COLOR="true" # Uncomment following line if you want to disable autosetting terminal title. # export DISABLE_AUTO_TITLE="true" diff --git a/themes/sorin.zsh-theme b/themes/sorin.zsh-theme index 601dbe5d..ecd092b8 100644 --- a/themes/sorin.zsh-theme +++ b/themes/sorin.zsh-theme @@ -2,15 +2,15 @@ # FILE: sorin.zsh-theme # DESCRIPTION: oh-my-zsh theme file. # AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) -# VERSION: 1.0.2 +# VERSION: 1.0.3 # SCREENSHOT: http://i.imgur.com/aipDQ.png # ------------------------------------------------------------------------------ -if [[ "$TERM" != "dumb" ]] && [[ "$DISABLE_LS_COLORS" != "true" ]]; then +if [[ "$DISABLE_COLOR" != "true" ]]; then MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}" local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}" - + PROMPT='%{$fg[cyan]%}%c$(git_prompt_info) %(!.%{$fg_bold[red]%}#.%{$fg_bold[green]%}❯)%{$reset_color%} ' ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[blue]%}git%{$reset_color%}:%{$fg[red]%}"