]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
lessfilter: Add, help filer for lesspipe.
authorSimon Ruderich <simon@ruderich.org>
Fri, 11 Feb 2011 20:18:24 +0000 (21:18 +0100)
committerSimon Ruderich <simon@ruderich.org>
Fri, 11 Feb 2011 20:18:24 +0000 (21:18 +0100)
Colors diff and patch files and displays directory contents.

Also update setup.sh.

lessfilter [new file with mode: 0755]
setup.sh

diff --git a/lessfilter b/lessfilter
new file mode 100755 (executable)
index 0000000..3570c79
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+case "$1" in
+    # Color diff files.
+    *.diff | *.patch)
+        < "$1" colordiff
+        ;;
+    *)
+        # Display directory contents.
+        if [ -d "$1" ]; then
+            echo "=> Contents of $1:"
+            ls "$1"
+            exit 0
+        fi
+
+        # We don't handle this format.
+        exit 1
+esac
+
+# No further processing by lesspipe necessary.
+exit 0
index 4318125a535ac89a35f71cf0f0429d0e978e8254..9137fa6464f5c24e7b135e97cc1c30f866093286 100755 (executable)
--- a/setup.sh
+++ b/setup.sh
@@ -53,6 +53,7 @@ link zsh/rc ~/.zshrc
 link zsh/logout ~/.zlogout
 
 # Link setup for additional files.
+link lessfilter ~/.lessfilter
 if installed colordiff; then
     link colordiffrc ~/.colordiffrc
 fi