Settings for less.
authorIain Patterson <me@iain.cx>
Tue, 27 Jul 2010 14:40:02 +0000 (15:40 +0100)
committerIain Patterson <me@iain.cx>
Tue, 3 Aug 2010 15:12:52 +0000 (16:12 +0100)
Set colours and character set if GNU less is found.

.profile.d/pager.bashrc [new file with mode: 0644]

diff --git a/.profile.d/pager.bashrc b/.profile.d/pager.bashrc
new file mode 100644 (file)
index 0000000..a138375
--- /dev/null
@@ -0,0 +1,42 @@
+# profile-required: TERM.bashrc
+less=$(find_working less 2>/dev/null)
+if [ $? = 0 ]; then
+  export PAGER=less
+  export GIT_PAGER=$PAGER
+  export LESSCHARSET=utf-8
+
+  # Colours.
+  case $(tput colors) in
+    256)
+      # Blink is green.
+      export LESS_TERMCAP_mb=$'\e[38;5;34m'
+      # Bold is blue.
+      export LESS_TERMCAP_md=$'\e[1m\e[38;5;33m'
+      # Standout is yellow.
+      export LESS_TERMCAP_so=$'\e[1m\e[38;5;226m'
+      # Underline is cyan.
+      export LESS_TERMCAP_us=$'\e[0m\e[38;5;38m'
+    ;;
+
+    88)
+      export LESS_TERMCAP_mb=$'\e[38;5;24m'
+      export LESS_TERMCAP_md=$'\e[1m\e[38;5;23m'
+      export LESS_TERMCAP_so=$'\e[1m\e[38;5;76m'
+      export LESS_TERMCAP_us=$'\e[0m\e[38;5;26m'
+    ;;
+
+    *)
+      export LESS_TERMCAP_mb=$'\e[32m'
+      export LESS_TERMCAP_md=$'\e[1m\e[36m'
+      export LESS_TERMCAP_so=$'\e[1m\e[33m'
+      export LESS_TERMCAP_us=$'\e[36m'
+    ;;
+  esac
+
+  export LESS_TERMCAP_me=$'\e[0m'
+  export LESS_TERMCAP_se=$'\e[0m'
+  export LESS_TERMCAP_ue=$'\e[0m'
+else
+  alias less=more
+fi
+unset less