1
0
Fork 0
mirror of synced 2024-11-26 17:25:35 -05:00

[utility] Use one-liner instead of "if then fi"

in recent tests included, to keep code simpler.
This commit is contained in:
Eric Nielsen 2017-05-15 08:59:17 -05:00
parent f15d6e4e02
commit 872926c84c

View file

@ -7,7 +7,7 @@
# #
if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then
# ls Colors # ls Colours
if (( ${+commands[dircolors]} )); then if (( ${+commands[dircolors]} )); then
# GNU # GNU
if [[ -s ${HOME}/.dir_colors ]]; then if [[ -s ${HOME}/.dir_colors ]]; then
@ -22,12 +22,8 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then
# BSD # BSD
# colours for ls and completion # colours for ls and completion
if (( ! ${+LSCOLORS} )); then (( ! ${+LSCOLORS} )) && export LSCOLORS='exfxcxdxbxGxDxabagacad'
export LSCOLORS='exfxcxdxbxGxDxabagacad' (( ! ${+LS_COLORS} )) && 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
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
# stock OpenBSD ls does not support colors at all, but colorls does. # stock OpenBSD ls does not support colors at all, but colorls does.
if [[ $OSTYPE == openbsd* ]]; then if [[ $OSTYPE == openbsd* ]]; then
@ -40,12 +36,8 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then
fi fi
# grep Colours # grep Colours
if (( ! ${+GREP_COLOR} )); then (( ! ${+GREP_COLOR} )) && export GREP_COLOR='37;45' #BSD
export GREP_COLOR='37;45' #BSD (( ! ${+GREP_COLORS} )) && export GREP_COLORS="mt=${GREP_COLOR}" #GNU
fi
if (( ! ${+GREP_COLORS} )); then
export GREP_COLORS="mt=${GREP_COLOR}" #GNU
fi
if [[ ${OSTYPE} == openbsd* ]]; then if [[ ${OSTYPE} == openbsd* ]]; then
if (( ${+commands[ggrep]} )); then if (( ${+commands[ggrep]} )); then
alias grep='ggrep --color=auto' alias grep='ggrep --color=auto'
@ -56,27 +48,13 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then
# less Colours # less Colours
if [[ ${PAGER} == 'less' ]]; then if [[ ${PAGER} == 'less' ]]; then
if (( ! ${+LESS_TERMCAP_mb} )); then (( ! ${+LESS_TERMCAP_mb} )) && export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking.
export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking. (( ! ${+LESS_TERMCAP_md} )) && export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold.
fi (( ! ${+LESS_TERMCAP_me} )) && export LESS_TERMCAP_me=$'\E[0m' # Ends mode.
if (( ! ${+LESS_TERMCAP_md} )); then (( ! ${+LESS_TERMCAP_se} )) && export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode.
export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold. (( ! ${+LESS_TERMCAP_so} )) && export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode.
fi (( ! ${+LESS_TERMCAP_ue} )) && export LESS_TERMCAP_ue=$'\E[0m' # Ends underline.
if (( ! ${+LESS_TERMCAP_me} )); then (( ! ${+LESS_TERMCAP_us} )) && export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline.
export LESS_TERMCAP_me=$'\E[0m' # Ends mode.
fi
if (( ! ${+LESS_TERMCAP_se} )); then
export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode.
fi
if (( ! ${+LESS_TERMCAP_so} )); then
export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode.
fi
if (( ! ${+LESS_TERMCAP_ue} )); then
export LESS_TERMCAP_ue=$'\E[0m' # Ends underline.
fi
if (( ! ${+LESS_TERMCAP_us} )); then
export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline.
fi
fi fi
fi fi