]> git.phdru.name Git - dotfiles.git/commitdiff
.profile: verify that `less' exists
authorOleg Broytman <phd@phdru.name>
Sat, 12 Mar 2016 21:57:11 +0000 (00:57 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 12 Mar 2016 21:57:11 +0000 (00:57 +0300)
Set PAGER to `more' if `less' doesn't exist.

.profile

index d4b94b089914a4392efded865f80d71a3d1609bc..965af5646a654accddc9c3c58e993bcd3e9b0b31 100644 (file)
--- a/.profile
+++ b/.profile
@@ -60,18 +60,22 @@ if [ -t 0 ] ; then
 
    stty sane erase ^H
 
+   if [ -n "`which less 2>/dev/null`" ]; then
+      HAS_LESS=true
+   fi
+
    case "$TERM" in
       linux)
          # mutt, python and vim
          BACKGROUND=DARK
          export BACKGROUND
-         . "$HOME"/lib/config/less/dark_bg
+         [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/dark_bg
       ;;
 
       *rxvt*|screen*|*term*|vt100)
          BACKGROUND=LIGHT
          export BACKGROUND
-         . "$HOME"/lib/config/less/light_bg
+         [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/light_bg
       ;;
    esac
 
@@ -79,18 +83,24 @@ if [ -t 0 ] ; then
        test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    fi
 
-   PAGER=less
-   LESS="FRXgimq"
-   case "$LC_CTYPE" in
-      *UTF-8) LESSCHARSET=utf-8
-      ;;
+   if [ -n "$HAS_LESS" ]; then
+      PAGER=less
+      LESS="FRXgimq"
+      case "$LC_CTYPE" in
+         *UTF-8) LESSCHARSET=utf-8
+         ;;
 
-      *) LESSCHARSET=koi8-r
-      ;;
-   esac
-   #LESSCHARDEF=32c.
-   LESSEDIT='vim ?lt+%lt. -- %f'
-   export PAGER LESS LESSCHARSET LESSEDIT # LESSCHARDEF
+         *) LESSCHARSET=koi8-r
+         ;;
+      esac
+      #LESSCHARDEF=32c.
+      LESSEDIT='vim ?lt+%lt. -- %f'
+      export LESS LESSCHARSET LESSEDIT # LESSCHARDEF
+
+   else
+      PAGER=more
+   fi
+   export PAGER
 
    EDITOR="$HOME"/.vim/vim.sh
    VISUAL="$EDITOR"
@@ -204,7 +214,7 @@ if [ -n "$DISPLAY" ]; then
    # mutt, python and vim
    BACKGROUND=LIGHT
    export BACKGROUND
-   . "$HOME"/lib/config/less/light_bg
+   [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/light_bg
 
    # BROWSERs
    BROWSER="firefox:seamonkey:chromium:google-chrome:opera:xlinks2:$BROWSER"
@@ -234,6 +244,8 @@ if [ -n "$DISPLAY" ]; then
    #export __GL_FSAA_MODE
 fi
 
+[ -n "$HAS_LESS" ] && unset HAS_LESS
+
 #
 # read in usepkg function
 # . "$HOME"/lib/config/usepkg.sh