bash: fix LS_COLORS
The solarize script evalss the output of the dircolors(1) but the LS_COLORS variable gets exported in its environmnent, not the calling shell where we actually need it so ls(1) and other programs wiill inherit it. Therefore, the evaluation of the dircolors(1) output is moved to the change_bg() function in the shell, so that the LS_COLORS variable is available to any children of the shell. The reason why I had missed this is that in most systems I have ls aliased to exa, which does not care about LS_COLORS and has its own coloring system. On cygwin, however, exa is not available and I noticed that the colors were missind; and indeed, on systems with exa the colors are also missing if I run ls as \ls.
This commit is contained in:
parent
f01bc4d599
commit
4e29ff39e7
2 changed files with 11 additions and 9 deletions
|
@ -128,11 +128,6 @@ main() {
|
|||
tmux set-environment -g BACKGROUND "$BACKGROUND"
|
||||
tmux source-file "$XDG_CONFIG_HOME/tmux/tmux-colors.conf"
|
||||
fi
|
||||
|
||||
ls_colors="$HOME/.config/dircolors/solarized-$BACKGROUND"
|
||||
if type dircolors >/dev/null && [ -f "$ls_colors" ]; then
|
||||
eval "$(dircolors "$ls_colors")"
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
||||
|
|
15
files/bashrc
15
files/bashrc
|
@ -11,7 +11,7 @@ export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
|||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
|
||||
export BACKGROUND="dark"
|
||||
export BACKGROUND="${BACKGROUND:-dark}"
|
||||
export EDITOR="nvim"
|
||||
export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc"
|
||||
export LANG="en_US.UTF-8"
|
||||
|
@ -75,7 +75,16 @@ if command -v brew >/dev/null 2>&1; then
|
|||
fi
|
||||
|
||||
stty -ixon # disable ctrl-s and ctrl-q
|
||||
command -v solarize >/dev/null && solarize
|
||||
|
||||
change_bg() {
|
||||
BACKGROUND="$1";
|
||||
command -v solarize &>/dev/null && solarize;
|
||||
|
||||
local f="$HOME/.config/dircolors/solarized-$BACKGROUND"
|
||||
[ -f "$f" ] && type dircolors &>/dev/null && eval "$(dircolors "$f")"
|
||||
}
|
||||
export change_bg
|
||||
change_bg "$BACKGROUND"
|
||||
|
||||
##############################################################################
|
||||
# Customize shell options & variables
|
||||
|
@ -203,8 +212,6 @@ alias light='change_bg light'
|
|||
|
||||
mkcd() { mkdir -p -- "$1" && cd -P -- "$1" || return; }
|
||||
|
||||
change_bg() { BACKGROUND="$1"; command -v solarize >/dev/null && solarize; }
|
||||
|
||||
##############################################################################
|
||||
# Run external customizations
|
||||
##############################################################################
|
||||
|
|
Loading…
Add table
Reference in a new issue