Diff
1diff --git a/README.md b/README.md
2index 556d4c8c5b474cb37fd7acd492478196ded04ebe..650fb00ea9aa34865adea0f40fef6608f0bf3863 100644
3--- a/README.md
4+++ b/README.md
5@@ -40,6 +40,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
6 - [Manual Installation](#manual-installation)
7 - [Installation Problems](#installation-problems)
8 - [Custom Plugins and Themes](#custom-plugins-and-themes)
9+ - [Disable GNU ls in macOS and freeBSD systems](#disable-gnu-ls)
10 - [Skip aliases](#skip-aliases)
11 - [Getting Updates](#getting-updates)
12 - [Updates verbosity](#updates-verbosity)
13@@ -278,6 +279,18 @@ If you have many functions that go well together, you can put them as a `XYZ.plu
14
15 If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
16
17+### Disable GNU ls in macOS and freeBSD systems
18+
19+<a name="disable-gnu-ls"></a>
20+
21+The default behaviour in Oh My Zsh is to use GNU `ls` even in macOS and freeBSD systems if it's installed (as
22+`gls` command) when enabling colorized `ls` in `lib/theme-and-appearance.zsh`. If you want to disable this
23+behaviour you can use zstyle-based config before sourcing `oh-my-zsh.sh`:
24+
25+```zsh
26+zstyle ':omz:lib:theme-and-appearance' gnu-ls no
27+```
28+
29 ### Skip aliases
30
31 <a name="remove-directories-aliases"></a>
32diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
33index d8859b04c8a7cd1b97d1e4be2701a3cea3801b52..96bdb00e5d8745574514168e74f1b40f1580911a 100644
34--- a/lib/theme-and-appearance.zsh
35+++ b/lib/theme-and-appearance.zsh
36@@ -20,10 +20,25 @@ if command diff --color /dev/null{,} &>/dev/null; then
37 }
38 fi
39
40-
41 # Don't set ls coloring if disabled
42 [[ "$DISABLE_LS_COLORS" != true ]] || return 0
43
44+# Default coloring for BSD-based ls
45+export LSCOLORS="Gxfxcxdxbxegedabagacad"
46+
47+# Default coloring for GNU-based ls
48+if [[ -z "$LS_COLORS" ]]; then
49+ # Define LS_COLORS via dircolors if available. Otherwise, set a default
50+ # equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
51+ if (( $+commands[dircolors] )); then
52+ [[ -f "$HOME/.dircolors" ]] \
53+ && source <(dircolors -b "$HOME/.dircolors") \
54+ || source <(dircolors -b)
55+ else
56+ 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"
57+ fi
58+fi
59+
60 function test-ls-args {
61 local cmd="$1" # ls, gls, colorls, ...
62 local args="${@[2,-1]}" # arguments except the first one
63@@ -50,7 +65,7 @@ case "$OSTYPE" in
64 test-ls-args ls -G && alias ls='ls -G'
65 # Only use GNU ls if installed and there are user defaults for $LS_COLORS,
66 # as the default coloring scheme is not very pretty
67- [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] \
68+ zstyle -T ':omz:lib:theme-and-appearance' gnu-ls \
69 && test-ls-args gls --color \
70 && alias ls='gls --color=tty'
71 ;;
72@@ -64,20 +79,3 @@ case "$OSTYPE" in
73 esac
74
75 unfunction test-ls-args
76-
77-
78-# Default coloring for BSD-based ls
79-export LSCOLORS="Gxfxcxdxbxegedabagacad"
80-
81-# Default coloring for GNU-based ls
82-if [[ -z "$LS_COLORS" ]]; then
83- # Define LS_COLORS via dircolors if available. Otherwise, set a default
84- # equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
85- if (( $+commands[dircolors] )); then
86- [[ -f "$HOME/.dircolors" ]] \
87- && source <(dircolors -b "$HOME/.dircolors") \
88- || source <(dircolors -b)
89- else
90- 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"
91- fi
92-fi