Skip to content

Instantly share code, notes, and snippets.

@ormaaj
Created June 6, 2022 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ormaaj/f4ca0f3735807c384a973380689101c3 to your computer and use it in GitHub Desktop.
Save ormaaj/f4ca0f3735807c384a973380689101c3 to your computer and use it in GitHub Desktop.
lol dircolors
function setupDirColors {
if [[ ${FUNCNAME[0]} == "${FUNCNAME[1]}" ]]; then
typeset -n LS_COLORS=$1
typeset dirc
if dirc=$("$(type -P dircolors 2>/dev/null)" -b); then
alias export=:; eval "$dirc"; unalias export
fi
else
typeset colors ret
if ! shopt -q expand_aliases; then
shopt -s expand_aliases
ret=
fi
"${FUNCNAME[0]}" colors
${colors:+\:} false && typeset -gx LS_COLORS=$colors
${ret+\:} shopt -u expand_aliases
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment