comparison rc/bash @ 270:0e41725e7d38

Grep, GNU Grep, Solaris Grep, etc.
author Edho Arief <edho@myconan.net>
date Thu, 24 Nov 2011 15:21:33 +0700
parents cd48b7a5cddd
children 003b0c8870b3
comparison
equal deleted inserted replaced
269:cd48b7a5cddd 270:0e41725e7d38
33 alias rd="rdesktop -g 1280x600 -K -a 16 -z -P -r sound:off -r clipboard:CLIPBOARD -5" 33 alias rd="rdesktop -g 1280x600 -K -a 16 -z -P -r sound:off -r clipboard:CLIPBOARD -5"
34 34
35 _has_gnu_ls= 35 _has_gnu_ls=
36 _has_gnu_grep= 36 _has_gnu_grep=
37 _ls="ls" 37 _ls="ls"
38 _grep="grep"
39 _has_posix_grep=y
40
38 case "$(uname -s)" in 41 case "$(uname -s)" in
39 Linux) 42 Linux)
40 _has_gnu_ls=y 43 _has_gnu_ls=y
41 _has_gnu_grep=y 44 _has_gnu_grep=y
42 ;; 45 ;;
43 SunOS) 46 SunOS)
47 _has_posix_grep=n
44 [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y 48 [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y
45 [ -x /usr/gnu/bin/grep ] && _has_gnu_grep=y 49 [ -x /usr/gnu/bin/grep ] && _has_gnu_grep=y
46 # Higher priority directories 50 # Higher priority directories
47 for i in {/opt/csw,/usr/gnu}/{,s}bin; do 51 for i in {/opt/csw,/usr/gnu}/{,s}bin; do
48 [ -d "${i}" ] && PATH="${i}:${PATH}" 52 [ -d "${i}" ] && PATH="${i}:${PATH}"
59 alias tmux="TERM=xterm-256color tmux" 63 alias tmux="TERM=xterm-256color tmux"
60 else 64 else
61 echo "No xterm-256color, using dtterm. Tmux title won't work." 65 echo "No xterm-256color, using dtterm. Tmux title won't work."
62 fi 66 fi
63 [ -f /usr/share/lib/terminfo/?/"${TERM}" ] || export TERM=dtterm 67 [ -f /usr/share/lib/terminfo/?/"${TERM}" ] || export TERM=dtterm
68 if command -v ggrep > /dev/null 2>&1; then
69 _has_gnu_grep=y
70 _grep="ggrep"
71 fi
64 ;; 72 ;;
65 OpenBSD) 73 OpenBSD)
66 PATH="${PATH}:/usr/X11R6/bin" 74 PATH="${PATH}:/usr/X11R6/bin"
67 if command -v gls > /dev/null 2>&1; then 75 if command -v gls > /dev/null 2>&1; then
68 _has_gnu_ls=y 76 _has_gnu_ls=y
84 export PATH="${PATH}:${_org_path}" 92 export PATH="${PATH}:${_org_path}"
85 ;; 93 ;;
86 esac 94 esac
87 95
88 [ "${_has_gnu_ls}" = y ] && alias ls="${_ls} -F --color=auto" 96 [ "${_has_gnu_ls}" = y ] && alias ls="${_ls} -F --color=auto"
89 [ "${_has_gnu_grep}" = y ] && alias grep="grep --color=auto" 97 if [ "${_has_gnu_grep}" = y ]; then
98 alias grep="${_grep} --color=auto"
99 _has_posix_grep=y
100 fi
101 if [ "${_has_posix_grep}" = y ]; then
102 alias fgrep="grep -F"
103 alias egrep="grep -E"
104 fi
90 105
91 unset _has_gnu_ls 106 unset _has_gnu_ls
92 unset _has_gnu_grep 107 unset _has_gnu_grep
108 unset _has_posix_grep
93 unset _ls 109 unset _ls
110 unset _grep
94 111
95 # Custom application I usually install and safe to prioritize 112 # Custom application I usually install and safe to prioritize
96 for i in {"${HOME}/app","/opt"}/{tmux,ruby19,node,tarsnap,symon,nginx}/{bin,sbin}; do 113 for i in {"${HOME}/app","/opt"}/{tmux,ruby19,node,tarsnap,symon,nginx}/{bin,sbin}; do
97 [ -d "${i}" ] && PATH="${i}:${PATH}" 114 [ -d "${i}" ] && PATH="${i}:${PATH}"
98 done 115 done