From 2b8928f2bd505189ea46724ceaf27373a9b4a6ec Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Tue, 8 Feb 2022 14:27:48 +0530 Subject: [PATCH 1/3] Make the ls color available for macos --- aliases/available/general.aliases.bash | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 3c29928d..e0a2d617 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -1,13 +1,18 @@ cite about-alias about-alias 'general aliases' -if ls --color -d . &> /dev/null -then - alias ls="ls --color=auto" -elif ls -G -d . &> /dev/null -then - alias ls='ls -G' # Compact view, show colors -fi +# color support for darwin and non-darwin os +# special thanks https://stackoverflow.com/a/27776822/10362396 +case "$(uname -s)" in + + Darwin) + alias ls='ls -G' + ;; + + *) + alias ls='ls --color=auto' + ;; +esac # List directory contents alias sl=ls From f7cba27f10fe2f6d47e292d308e694c1b9b2f8ff Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 29 Jan 2022 22:17:42 -0800 Subject: [PATCH 2/3] lib/appearance: `shellcheck` && `shfmt` --- clean_files.txt | 1 + lib/appearance.bash | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clean_files.txt b/clean_files.txt index 54180c19..016915ac 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -76,6 +76,7 @@ completion/available/vuejs.completion.bash completion/available/wpscan.completion.bash # libraries +lib/appearance.bash lib/colors.bash lib/helpers.bash lib/history.bash diff --git a/lib/appearance.bash b/lib/appearance.bash index 6d0ef2ff..9f02f74f 100644 --- a/lib/appearance.bash +++ b/lib/appearance.bash @@ -1,19 +1,18 @@ -#!/usr/bin/env bash +# shellcheck shell=bash # colored ls export LSCOLORS='Gxfxcxdxdxegedabagacad' -if [[ -z "$CUSTOM_THEME_DIR" ]]; then - CUSTOM_THEME_DIR="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/themes" -fi +: "${CUSTOM_THEME_DIR:="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/themes"}" # Load the theme -if [[ $BASH_IT_THEME ]]; then - if [[ -f $BASH_IT_THEME ]]; then - source $BASH_IT_THEME - elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then - source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" - else - source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" - fi +# shellcheck disable=SC1090 +if [[ -n "${BASH_IT_THEME:-}" ]]; then + if [[ -f "${BASH_IT_THEME}" ]]; then + source "${BASH_IT_THEME}" + elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then + source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" + else + source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" + fi fi From 0286a50fcdb5df977bb5f2460855f3cbc110176b Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sun, 6 Feb 2022 15:22:52 -0800 Subject: [PATCH 3/3] lib/appearance: export `$CLICOLOR` instead of `$LSCOLOR` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alsö, since the *value* of `$CLICOLOR` is not used anywhere, overload it to count the number of colors available for use elsewhere. --- lib/appearance.bash | 4 ++-- lib/log.bash | 2 +- themes/base.theme.bash | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/appearance.bash b/lib/appearance.bash index 9f02f74f..e77a1a80 100644 --- a/lib/appearance.bash +++ b/lib/appearance.bash @@ -1,7 +1,7 @@ # shellcheck shell=bash -# colored ls -export LSCOLORS='Gxfxcxdxdxegedabagacad' +: "${CLICOLOR:=$(tput colors)}" +export CLICOLOR : "${CUSTOM_THEME_DIR:="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/themes"}" diff --git a/lib/log.bash b/lib/log.bash index 87b9ddf1..a8cb8080 100644 --- a/lib/log.bash +++ b/lib/log.bash @@ -45,7 +45,7 @@ function _bash-it-log-prefix-by-path() { function _has_colors() { # Check that stdout is a terminal, and that it has at least 8 colors. - [[ -t 1 && "${_bash_it_available_colors:=$(tput colors 2> /dev/null)}" -ge 8 ]] + [[ -t 1 && "${CLICOLOR:=$(tput colors 2> /dev/null)}" -ge 8 ]] } function _bash-it-log-message() { diff --git a/themes/base.theme.bash b/themes/base.theme.bash index d7479b3f..77c8b621 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -1,6 +1,10 @@ # shellcheck shell=bash # shellcheck disable=SC2034 # Expected behavior for themes. +# Colors for listing files, using default color scheme. +# To customize color scheme by theme, check out https://geoff.greer.fm/lscolors/ +export CLICOLOR LSCOLORS LS_COLORS + CLOCK_CHAR_THEME_PROMPT_PREFIX='' CLOCK_CHAR_THEME_PROMPT_SUFFIX='' CLOCK_THEME_PROMPT_PREFIX=''