Skip to content

Instantly share code, notes, and snippets.

@vain
Created April 9, 2012 08:29
Show Gist options
  • Select an option

  • Save vain/2342295 to your computer and use it in GitHub Desktop.

Select an option

Save vain/2342295 to your computer and use it in GitHub Desktop.

Revisions

  1. vain created this gist Apr 9, 2012.
    52 changes: 52 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    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
    }