From 2657b88d4b57c6501abb0a5260ec60c0fd2f2db9 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Tue, 23 Feb 2021 13:57:02 -0500 Subject: [PATCH] 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! --- .bashrc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.bashrc b/.bashrc index 5746cd1..4bdfa11 100644 --- 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() { -- libgit2 0.28.4