From efa7c7b7ff72953368dfaba979e3014826bf1837 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Sun, 2 Oct 2016 19:15:57 -0700 Subject: [PATCH 1/4] set better default colors for GNU ls instead of none. GNU coreutils ship a color setup command by default which can be used to set a good default color theme for ls: https://www.gnu.org/software/coreutils/manual/html_node/dircolors-invocation.html --- lib/theme-and-appearance.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 5c5bb0e6d..585f872e1 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -5,7 +5,7 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad" # Enable ls colors if [ "$DISABLE_LS_COLORS" != "true" ] then - # Find the option for using colors in ls, depending on the version: Linux or BSD + # Find the option for using colors in ls, depending on the version: GNU or BSD if [[ "$(uname -s)" == "NetBSD" ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G @@ -18,6 +18,8 @@ then gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else + # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. + type dircolors >/dev/null 2>&1 && eval "$(dircolors)" ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' fi fi From 6c08286c8e0ca4d2b48679d2692f0ce4ac443f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 01:25:07 +0200 Subject: [PATCH 2/4] Use `$commands[]` to check for command existence --- lib/theme-and-appearance.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 585f872e1..43e245e16 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -19,7 +19,8 @@ then colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. - type dircolors >/dev/null 2>&1 && eval "$(dircolors)" + (( $+commands[dircolors] )) && eval "$(dircolors)" + ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' fi fi From 6304a789ab280e4a6e984faedd4b046f703327e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 01:25:36 +0200 Subject: [PATCH 3/4] Only set default LS_COLORS if not set before Also, force the use of Bourne-style shell syntax with `dircolors -b`. --- lib/theme-and-appearance.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 43e245e16..621cd067b 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -19,7 +19,9 @@ then colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. - (( $+commands[dircolors] )) && eval "$(dircolors)" + if [[ -z "$LS_COLORS" ]]; then + (( $+commands[dircolors] )) && eval "$(dircolors -b)" + fi ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' fi From c2e3a410ea7975f72bf7f0d5b4550ac4375b1e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 01:24:48 +0200 Subject: [PATCH 4/4] Fix style of theme-and-appearance.zsh --- lib/theme-and-appearance.zsh | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 621cd067b..a3bb24677 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -1,41 +1,37 @@ # ls colors autoload -U colors && colors -export LSCOLORS="Gxfxcxdxbxegedabagacad" # Enable ls colors -if [ "$DISABLE_LS_COLORS" != "true" ] -then - # Find the option for using colors in ls, depending on the version: GNU or BSD +export LSCOLORS="Gxfxcxdxbxegedabagacad" + +if [[ "$DISABLE_LS_COLORS" != "true" ]]; then + # Find the option for using colors in ls, depending on the version if [[ "$(uname -s)" == "NetBSD" ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G - gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' + gls --color -d . &>/dev/null && alias ls='gls --color=tty' elif [[ "$(uname -s)" == "OpenBSD" ]]; then # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, # with color and multibyte support) are available from ports. "colorls" # will be installed on purpose and can't be pulled in by installing # coreutils, so prefer it to "gls". - gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' - colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' + gls --color -d . &>/dev/null && alias ls='gls --color=tty' + colorls -G -d . &>/dev/null && alias ls='colorls -G' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. if [[ -z "$LS_COLORS" ]]; then (( $+commands[dircolors] )) && eval "$(dircolors -b)" fi - ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' + ls --color -d . &>/dev/null && alias ls='ls --color=tty' || alias ls='ls -G' fi fi setopt auto_cd setopt multios +setopt prompt_subst -if [[ x$WINDOW != x ]] -then - SCREEN_NO="%B$WINDOW%b " -else - SCREEN_NO="" -fi +[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO="" # Apply theming defaults PS1="%n@%m:%~%# " @@ -45,6 +41,3 @@ ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of th ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean - -# Setup the prompt with pretty colors -setopt prompt_subst