Created
April 9, 2012 08:29
-
-
Save vain/2342295 to your computer and use it in GitHub Desktop.
Usage of colored ls in an XTerm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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