From 9e675508b25e4bd8ee1bdf4c42444bd497bdb468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=B3ichiel=20=E2=84=9Boos?= Date: Wed, 10 May 2017 10:27:13 +0200 Subject: [PATCH 1/5] Prevent overwriting of defined environment vars Env vars set in `.zshenv` should not be overwritten. However, it is sourced before Zim loads, making Zim overwrite the settings. Fixes: #175 --- modules/utility/init.zsh | 44 ++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index f8e2cfb..48130a6 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -22,8 +22,12 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then # BSD # colours for ls and completion - export LSCOLORS='exfxcxdxbxGxDxabagacad' - export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' + if [[ -z ${LSCOLORS} ]]; then + export LSCOLORS='exfxcxdxbxGxDxabagacad' + fi + if [[ -z ${LS_COLORS} ]]; then + export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' + fi # stock OpenBSD ls does not support colors at all, but colorls does. if [[ $OSTYPE == openbsd* ]]; then @@ -36,8 +40,12 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then fi # grep Colours - export GREP_COLOR='37;45' #BSD - export GREP_COLORS="mt=${GREP_COLOR}" #GNU + if [[ -z ${GREP_COLOR} ]]; then + export GREP_COLOR='37;45' #BSD + fi + if [[ -z ${GREP_COLORS} ]]; then + export GREP_COLORS="mt=${GREP_COLOR}" #GNU + fi if [[ ${OSTYPE} == openbsd* ]]; then if (( ${+commands[ggrep]} )); then alias grep='ggrep --color=auto' @@ -48,13 +56,27 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then # less Colours if [[ ${PAGER} == 'less' ]]; then - export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking. - export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold. - export LESS_TERMCAP_me=$'\E[0m' # Ends mode. - export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode. - export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode. - export LESS_TERMCAP_ue=$'\E[0m' # Ends underline. - export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline. + if [[ -z ${LESS_TERMCAP_mb} ]]; then + export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking. + fi + if [[ -z ${LESS_TERMCAP_md} ]]; then + export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold. + fi + if [[ -z ${LESS_TERMCAP_me} ]]; then + export LESS_TERMCAP_me=$'\E[0m' # Ends mode. + fi + if [[ -z ${LESS_TERMCAP_se} ]]; then + export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode. + fi + if [[ -z ${LESS_TERMCAP_so} ]]; then + export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode. + fi + if [[ -z ${LESS_TERMCAP_ue} ]]; then + export LESS_TERMCAP_ue=$'\E[0m' # Ends underline. + fi + if [[ -z ${LESS_TERMCAP_us} ]]; then + export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline. + fi fi fi From 4d86eb6d781a458ddf6a5b7b3269ffa15c91b657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=B3ichiel=20=E2=84=9Boos?= Date: Wed, 10 May 2017 19:56:26 +0200 Subject: [PATCH 2/5] Change conditions to zsh style --- modules/utility/init.zsh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index 48130a6..0ded30a 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -22,10 +22,10 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then # BSD # colours for ls and completion - if [[ -z ${LSCOLORS} ]]; then + if (( ${+LSCOLORS} )); then export LSCOLORS='exfxcxdxbxGxDxabagacad' fi - if [[ -z ${LS_COLORS} ]]; then + if (( ${+LS_COLORS} )); then export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' fi @@ -40,10 +40,10 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then fi # grep Colours - if [[ -z ${GREP_COLOR} ]]; then + if (( ${+GREP_COLOR} )); then export GREP_COLOR='37;45' #BSD fi - if [[ -z ${GREP_COLORS} ]]; then + if (( ${+GREP_COLORS} )); then export GREP_COLORS="mt=${GREP_COLOR}" #GNU fi if [[ ${OSTYPE} == openbsd* ]]; then @@ -56,25 +56,25 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then # less Colours if [[ ${PAGER} == 'less' ]]; then - if [[ -z ${LESS_TERMCAP_mb} ]]; then + if (( ${+LESS_TERMCAP_mb} )); then export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking. fi - if [[ -z ${LESS_TERMCAP_md} ]]; then + if (( ${+LESS_TERMCAP_md} )); then export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold. fi - if [[ -z ${LESS_TERMCAP_me} ]]; then + if (( ${+LESS_TERMCAP_me} )); then export LESS_TERMCAP_me=$'\E[0m' # Ends mode. fi - if [[ -z ${LESS_TERMCAP_se} ]]; then + if (( ${+LESS_TERMCAP_se} )); then export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode. fi - if [[ -z ${LESS_TERMCAP_so} ]]; then + if (( ${+LESS_TERMCAP_so} )); then export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode. fi - if [[ -z ${LESS_TERMCAP_ue} ]]; then + if (( ${+LESS_TERMCAP_ue} )); then export LESS_TERMCAP_ue=$'\E[0m' # Ends underline. fi - if [[ -z ${LESS_TERMCAP_us} ]]; then + if (( ${+LESS_TERMCAP_us} )); then export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline. fi fi From 5566a41f7ca10c2f045abc73a0c7e5930ce95b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=B3ichiel=20=E2=84=9Boos?= Date: Thu, 11 May 2017 12:06:56 +0200 Subject: [PATCH 3/5] Negate var test conditions We want to know if the vars are 'not' set. --- modules/utility/init.zsh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index 0ded30a..6110705 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -22,10 +22,10 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then # BSD # colours for ls and completion - if (( ${+LSCOLORS} )); then + if ! (( ${+LSCOLORS} )); then export LSCOLORS='exfxcxdxbxGxDxabagacad' fi - if (( ${+LS_COLORS} )); then + if ! (( ${+LS_COLORS} )); then export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' fi @@ -40,14 +40,14 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then fi # grep Colours - if (( ${+GREP_COLOR} )); then + if ! (( ${+GREP_COLOR} )); then export GREP_COLOR='37;45' #BSD fi - if (( ${+GREP_COLORS} )); then + if ! (( ${+GREP_COLORS} )); then export GREP_COLORS="mt=${GREP_COLOR}" #GNU fi if [[ ${OSTYPE} == openbsd* ]]; then - if (( ${+commands[ggrep]} )); then + if ! (( ${+commands[ggrep]} )); then alias grep='ggrep --color=auto' fi else @@ -56,25 +56,25 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then # less Colours if [[ ${PAGER} == 'less' ]]; then - if (( ${+LESS_TERMCAP_mb} )); then + if ! (( ${+LESS_TERMCAP_mb} )); then export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking. fi - if (( ${+LESS_TERMCAP_md} )); then + if ! (( ${+LESS_TERMCAP_md} )); then export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold. fi - if (( ${+LESS_TERMCAP_me} )); then + if ! (( ${+LESS_TERMCAP_me} )); then export LESS_TERMCAP_me=$'\E[0m' # Ends mode. fi - if (( ${+LESS_TERMCAP_se} )); then + if ! (( ${+LESS_TERMCAP_se} )); then export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode. fi - if (( ${+LESS_TERMCAP_so} )); then + if ! (( ${+LESS_TERMCAP_so} )); then export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode. fi - if (( ${+LESS_TERMCAP_ue} )); then + if ! (( ${+LESS_TERMCAP_ue} )); then export LESS_TERMCAP_ue=$'\E[0m' # Ends underline. fi - if (( ${+LESS_TERMCAP_us} )); then + if ! (( ${+LESS_TERMCAP_us} )); then export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline. fi fi From a1534869447f092371147e927304c5ad4967f516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=B3ichiel=20=E2=84=9Boos?= Date: Thu, 11 May 2017 12:08:35 +0200 Subject: [PATCH 4/5] Remove negation for ggrep Since it was not part of this patch --- modules/utility/init.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index 6110705..fad2ea0 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -47,7 +47,7 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then export GREP_COLORS="mt=${GREP_COLOR}" #GNU fi if [[ ${OSTYPE} == openbsd* ]]; then - if ! (( ${+commands[ggrep]} )); then + if (( ${+commands[ggrep]} )); then alias grep='ggrep --color=auto' fi else From 66c35ce82c651e4ecc8add5464f93a3c6fe16590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=B3ichiel=20=E2=84=9Boos?= Date: Sun, 14 May 2017 11:05:42 +0200 Subject: [PATCH 5/5] Move exclamation mar inside of var test braces --- modules/utility/init.zsh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index fad2ea0..2501569 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -22,10 +22,10 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then # BSD # colours for ls and completion - if ! (( ${+LSCOLORS} )); then + if (( ! ${+LSCOLORS} )); then export LSCOLORS='exfxcxdxbxGxDxabagacad' fi - if ! (( ${+LS_COLORS} )); then + if (( ! ${+LS_COLORS} )); then export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' fi @@ -40,10 +40,10 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then fi # grep Colours - if ! (( ${+GREP_COLOR} )); then + if (( ! ${+GREP_COLOR} )); then export GREP_COLOR='37;45' #BSD fi - if ! (( ${+GREP_COLORS} )); then + if (( ! ${+GREP_COLORS} )); then export GREP_COLORS="mt=${GREP_COLOR}" #GNU fi if [[ ${OSTYPE} == openbsd* ]]; then @@ -56,25 +56,25 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then # less Colours if [[ ${PAGER} == 'less' ]]; then - if ! (( ${+LESS_TERMCAP_mb} )); then + if (( ! ${+LESS_TERMCAP_mb} )); then export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking. fi - if ! (( ${+LESS_TERMCAP_md} )); then + if (( ! ${+LESS_TERMCAP_md} )); then export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold. fi - if ! (( ${+LESS_TERMCAP_me} )); then + if (( ! ${+LESS_TERMCAP_me} )); then export LESS_TERMCAP_me=$'\E[0m' # Ends mode. fi - if ! (( ${+LESS_TERMCAP_se} )); then + if (( ! ${+LESS_TERMCAP_se} )); then export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode. fi - if ! (( ${+LESS_TERMCAP_so} )); then + if (( ! ${+LESS_TERMCAP_so} )); then export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode. fi - if ! (( ${+LESS_TERMCAP_ue} )); then + if (( ! ${+LESS_TERMCAP_ue} )); then export LESS_TERMCAP_ue=$'\E[0m' # Ends underline. fi - if ! (( ${+LESS_TERMCAP_us} )); then + if (( ! ${+LESS_TERMCAP_us} )); then export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline. fi fi