Skip to content

Commit

Permalink
Use $LS_COLORS to display the colors of the file names if possible.
Browse files Browse the repository at this point in the history
Close #19.
  • Loading branch information
xuhdev committed Oct 19, 2016
1 parent 1fa7c03 commit 066793c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 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 @@ -484,6 +479,9 @@ k () {
NAME=$'\e['"$K_COLOR_OW"'m'"$NAME"$'\e[0m';
fi
NAME=$'\e['"$K_COLOR_DI"'m'"$NAME"$'\e[0m';
elif [[ "$LS_COLORS" ]] && ls --color -d . &>/dev/null; then
# We are using an ls that supports using colors from $LS_COLORS (probably GNU ls here)
NAME="$(ls --color=always "${base_dir:=.}/$NAME")"
elif [[ $IS_SYMLINK == 1 ]]; then NAME=$'\e['"$K_COLOR_LN"'m'"$NAME"$'\e[0m';
elif [[ $IS_SOCKET == 1 ]]; then NAME=$'\e['"$K_COLOR_SO"'m'"$NAME"$'\e[0m';
elif [[ $IS_PIPE == 1 ]]; then NAME=$'\e['"$K_COLOR_PI"'m'"$NAME"$'\e[0m';
Expand Down

0 comments on commit 066793c

Please sign in to comment.