summaryrefslogtreecommitdiff
path: root/lib/theme-and-appearance.zsh
diff options
context:
space:
mode:
authorCarlo Sala <carlosalag@protonmail.com>2023-05-02 12:41:01 +0200
committerCarlo Sala <carlosalag@protonmail.com>2023-05-06 13:39:01 +0200
commitc5208867f1eb46f722e040b239150817abec87a6 (patch)
tree79fda8f6be2827ac4200cb46b2bd59cb022a87a9 /lib/theme-and-appearance.zsh
parent5a3f565e7d4371db92ba574f231b396c2c8c9a19 (diff)
downloadzsh-c5208867f1eb46f722e040b239150817abec87a6.tar.gz
zsh-c5208867f1eb46f722e040b239150817abec87a6.tar.bz2
zsh-c5208867f1eb46f722e040b239150817abec87a6.zip
feat(theme-and-appearance): allow disabling gnu-ls in bsd
To disable gnu-ls (`gls`) even if it's installed in freeBSD and macOS you can set it up with: ```zsh zstyle ':omz:lib:theme-and-appearance' gnu-ls no ``` Closes #11647
Diffstat (limited to 'lib/theme-and-appearance.zsh')
-rw-r--r--lib/theme-and-appearance.zsh36
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index d8859b04c..96bdb00e5 100644
--- a/lib/theme-and-appearance.zsh
+++ b/lib/theme-and-appearance.zsh
@@ -20,10 +20,25 @@ if command diff --color /dev/null{,} &>/dev/null; then
}
fi
-
# Don't set ls coloring if disabled
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
+# Default coloring for BSD-based ls
+export LSCOLORS="Gxfxcxdxbxegedabagacad"
+
+# Default coloring for GNU-based ls
+if [[ -z "$LS_COLORS" ]]; then
+ # Define LS_COLORS via dircolors if available. Otherwise, set a default
+ # equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
+ if (( $+commands[dircolors] )); then
+ [[ -f "$HOME/.dircolors" ]] \
+ && source <(dircolors -b "$HOME/.dircolors") \
+ || source <(dircolors -b)
+ else
+ export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
+ fi
+fi
+
function test-ls-args {
local cmd="$1" # ls, gls, colorls, ...
local args="${@[2,-1]}" # arguments except the first one
@@ -50,7 +65,7 @@ case "$OSTYPE" in
test-ls-args ls -G && alias ls='ls -G'
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
# as the default coloring scheme is not very pretty
- [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] \
+ zstyle -T ':omz:lib:theme-and-appearance' gnu-ls \
&& test-ls-args gls --color \
&& alias ls='gls --color=tty'
;;
@@ -64,20 +79,3 @@ case "$OSTYPE" in
esac
unfunction test-ls-args
-
-
-# Default coloring for BSD-based ls
-export LSCOLORS="Gxfxcxdxbxegedabagacad"
-
-# Default coloring for GNU-based ls
-if [[ -z "$LS_COLORS" ]]; then
- # Define LS_COLORS via dircolors if available. Otherwise, set a default
- # equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
- if (( $+commands[dircolors] )); then
- [[ -f "$HOME/.dircolors" ]] \
- && source <(dircolors -b "$HOME/.dircolors") \
- || source <(dircolors -b)
- else
- export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
- fi
-fi