Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use $LS_COLORS to display the colors of the file names if possible. #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions k.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ k () {
K_COLOR_OW=$(_k_bsd_to_ansi $LSCOLORS[21] $LSCOLORS[22])
fi

# read colors if linux and $LS_COLORS is defined
# if [[ $(uname) == 'Linux' && -n $LS_COLORS ]]; then

# fi

# ----------------------------------------------------------------------------
# Loop over passed directories and files to display
# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -476,7 +471,12 @@ k () {
# But we don't want to quote '.'; so instead we escape the escape manually and use q-
NAME="${${NAME##*/}//$'\e'/\\e}" # also propagate changes to SYMLINK_TARGET below

if [[ $IS_DIRECTORY == 1 ]]; then
if [[ "$LS_COLORS" ]] && ls --color -d . &>/dev/null; then
# We are using an ls that supports using colors from $LS_COLORS (probably GNU ls here)
pushd "${base_dir}" &>/dev/null
NAME="$(ls --color=always -d "$NAME")"
popd &>/dev/null
elif [[ $IS_DIRECTORY == 1 ]]; then
if [[ $IS_WRITABLE_BY_OTHERS == 1 ]]; then
if [[ $HAS_STICKY_BIT == 1 ]]; then
NAME=$'\e['"$K_COLOR_TW"'m'"$NAME"$'\e[0m';
Expand Down