dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit 2657b88d4b57c6501abb0a5260ec60c0fd2f2db9 (patch)
parent 779611c745961c82a8fb3fd1fa467b5aa81ec60b
Author: Alex Karle <alex@alexkarle.com>
Date:   Tue, 23 Feb 2021 13:57:02 -0500

bash: Fix ls colors in "pretty color" mode

The patterns are:

	colorls -G # OpenBSD
	ls -G      # macOS
	ls --color # Linux

I only really use colored ls on Linux right now, but I figured it
doesn't hurt to include macOS / OpenBSD in case one day I do want it!

Diffstat:
M.bashrc | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/.bashrc b/.bashrc @@ -30,8 +30,13 @@ HISTCONTROL=ignoreboth # Don't store duped / whitespace-led commands in history PROMPT_COMMAND="history -a" # Record history after each command if [ -n "$PRETTY_COLORS" ]; then - if command -v colorls >/dev/null; then - alias ls=colorls + # ls colors + if ls --color >/dev/null 2>&1; then + alias ls='ls --color' + elif ls -G >/dev/null 2>&1; then + alias ls='ls -G' + elif colorls -G >/dev/null 2>&1; then + alias ls='colorls -G' fi parse_git_dirty() {