Skip to content

Instantly share code, notes, and snippets.

@vain
Created April 9, 2012 08:29
Show Gist options
  • Save vain/2342295 to your computer and use it in GitHub Desktop.
Save vain/2342295 to your computer and use it in GitHub Desktop.
Usage of colored ls in an XTerm
wrapoff()
{
# Wraparound aus, damit lange Zeilen nicht umgebrochen werden.
# Das ist eine XTerm-Einstellung, mache das also nur, wenn stdout
# ein solches ist und auch wirklich ein Terminal ist, also nicht
# gerade umgeleitet wird.
[[ -t 1 ]] || return
case "$TERM" in
xterm*|rxvt*) echo -n $'\e[?7l' ;;
esac
}
wrapon()
{
# Wraparound wieder an.
[[ -t 1 ]] || return
case "$TERM" in
xterm*|rxvt*) echo -n $'\e[?7h' ;;
esac
}
l()
{
wrapoff
unset a
if [[ "$1" == "+a" ]]
then
shift
else
a="a"
fi
ls -Fl$a --block-size="'1" --color=always --group-directories-first \
-q "$@" | ~void/bin/coloredls.pl
# Merke dir den Rückgabewert von ls. Der Rest ist egal.
ret=${PIPESTATUS[0]}
wrapon
return $ret
}
ll()
{
l "$@" | less
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment