Mercurial > ec-dotfiles
annotate rc/bashrc @ 677:b95069a1f664
[irbrc] Disable autocomplete
It's kinda slow and moves things around.
| author | nanaya <me@nanaya.pro> | 
|---|---|
| date | Fri, 08 Apr 2022 13:47:15 +0900 | 
| parents | 35c26d9dcaa7 | 
| children | 71254a6ddb4c | 
| rev | line source | 
|---|---|
| 43 | 1 #!/usr/bin/env bash | 
| 2 | |
| 242 
ebfa844d2ef8
[bash] Also ensures interactive terminal.
 Edho Arief <edho@myconan.net> parents: 
238diff
changeset | 3 case "${-}" in | 
| 
ebfa844d2ef8
[bash] Also ensures interactive terminal.
 Edho Arief <edho@myconan.net> parents: 
238diff
changeset | 4 *i*) ;; | 
| 
ebfa844d2ef8
[bash] Also ensures interactive terminal.
 Edho Arief <edho@myconan.net> parents: 
238diff
changeset | 5 *) return;; | 
| 
ebfa844d2ef8
[bash] Also ensures interactive terminal.
 Edho Arief <edho@myconan.net> parents: 
238diff
changeset | 6 esac | 
| 
ebfa844d2ef8
[bash] Also ensures interactive terminal.
 Edho Arief <edho@myconan.net> parents: 
238diff
changeset | 7 | 
| 533 
77c1f9e624a3
Rename prefix to `.ec.` instead of `.ecos_`.
 edogawaconan <me@myconan.net> parents: 
530diff
changeset | 8 if [ "${EC_BASH_LOADED}" != "yes" ]; then | 
| 
77c1f9e624a3
Rename prefix to `.ec.` instead of `.ecos_`.
 edogawaconan <me@myconan.net> parents: 
530diff
changeset | 9 EC_BASH_LOADED="yes" | 
| 122 
eacc854eae67
Export should be used since it inherited to subshell (eg. tmux). Also hasten exit instead of fi on the bottom of file.
 Edho Prima Arief <edho@myconan.net> parents: 
117diff
changeset | 10 else | 
| 
eacc854eae67
Export should be used since it inherited to subshell (eg. tmux). Also hasten exit instead of fi on the bottom of file.
 Edho Prima Arief <edho@myconan.net> parents: 
117diff
changeset | 11 return | 
| 
eacc854eae67
Export should be used since it inherited to subshell (eg. tmux). Also hasten exit instead of fi on the bottom of file.
 Edho Prima Arief <edho@myconan.net> parents: 
117diff
changeset | 12 fi | 
| 117 
548cf46e9cb4
Ensures no double loading using C-style variable test.
 Edho Prima Arief <edho@myconan.net> parents: 
112diff
changeset | 13 | 
| 533 
77c1f9e624a3
Rename prefix to `.ec.` instead of `.ecos_`.
 edogawaconan <me@myconan.net> parents: 
530diff
changeset | 14 [ -f "${HOME}/.ec.bash.before" ] && . "${HOME}/.ec.bash.before" | 
| 49 
b924652e169d
[bash] Various tweaks: prompt, unset for check variables, etc
 Edho Prima Arief <me@myconan.net> parents: 
48diff
changeset | 15 | 
| 385 | 16 _org_path="${PATH}" | 
| 386 | 17 | 
| 587 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 18 # ensure correct window size at all time | 
| 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 19 # noticeably in FreebSD + tmux + vim: | 
| 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 20 # 1. start tmux | 
| 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 21 # 2. start vim in the session | 
| 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 22 # 3. split pane | 
| 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 23 # 4. quit vim | 
| 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 24 # 5. wrong COLUMNS or LINES | 
| 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 25 shopt -s checkwinsize | 
| 
394f19c180a2
Ensure correct terminal size variables
 nanaya <me@myconan.net> parents: 
584diff
changeset | 26 | 
| 610 | 27 set +H | 
| 28 | |
| 386 | 29 # Basic PATH | 
| 468 | 30 export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/games" | 
| 385 | 31 | 
| 520 
a60af1e859e4
set PATH before calling uname.
 edogawaconan <me@myconan.net> parents: 
516diff
changeset | 32 _os="$(uname -s)" | 
| 628 | 33 _os_r="$(uname -r)" | 
| 520 
a60af1e859e4
set PATH before calling uname.
 edogawaconan <me@myconan.net> parents: 
516diff
changeset | 34 | 
| 385 | 35 # pkgsrc | 
| 36 if test -d /usr/pkg; then | |
| 37 PATH="${PATH}:/usr/pkg/bin:/usr/pkg/sbin" | |
| 38 if test -d /usr/pkg/java/openjdk7; then | |
| 39 # OpenJDK 7 in pkgsrc | |
| 40 PATH="${PATH}:/usr/pkg/java/openjdk7/bin" | |
| 41 fi | |
| 42 fi | |
| 460 | 43 | 
| 387 | 44 # OpenBSD X11 | 
| 45 test -d /usr/X11R6/bin && PATH="${PATH}:/usr/X11R6/bin" | |
| 46 # PostgreSQL Yum | |
| 440 
abbdb936a36a
Automated pgsql yum version detect.
 Edho Arief <edho@myconan.net> parents: 
439diff
changeset | 47 # Defaults to last version available. | 
| 521 | 48 for _pgbindir in /usr/pgsql-*/bin; do test; done | 
| 440 
abbdb936a36a
Automated pgsql yum version detect.
 Edho Arief <edho@myconan.net> parents: 
439diff
changeset | 49 test -d "${_pgbindir}" && PATH="${_pgbindir}:${PATH}" | 
| 
abbdb936a36a
Automated pgsql yum version detect.
 Edho Arief <edho@myconan.net> parents: 
439diff
changeset | 50 unset _pgbindir | 
| 385 | 51 | 
| 439 | 52 # PostgreSQL EnterpriseDB | 
| 53 # Defaults to last version available. | |
| 521 | 54 for _pgbindir in /opt/PostgreSQL/*/bin; do test; done | 
| 439 | 55 test -d "${_pgbindir}" && PATH="${_pgbindir}:${PATH}" | 
| 56 unset _pgbindir | |
| 57 | |
| 372 | 58 # Nuke currently defined functions | 
| 396 | 59 unset -f $(set | grep ' \(\)$' | cut -d ' ' -f 1) | 
| 372 | 60 | 
| 374 | 61 # Nuke bash-completion | 
| 62 complete -r | |
| 63 | |
| 380 | 64 # Nuke aliases | 
| 65 unalias -a | |
| 66 | |
| 111 
fd8dbd4bb758
ls color for freebsd, history control.
 Edho Prima Arief <edho@myconan.net> parents: 
106diff
changeset | 67 shopt -s histappend | 
| 499 | 68 HISTSIZE=20000 | 
| 69 HISTFILESIZE=$HISTSIZE | |
| 70 HISTCONTROL=ignorespace:ignoredups:erasedups | |
| 71 PROMPT_COMMAND='history -a; history -c; history -r' | |
| 111 
fd8dbd4bb758
ls color for freebsd, history control.
 Edho Prima Arief <edho@myconan.net> parents: 
106diff
changeset | 72 | 
| 414 | 73 export PAGER=more | 
| 74 export EDITOR=vi | |
| 89 
29bd7f6ef58a
Explicit LANG declaration.
 Edho Prima Arief <me@myconan.net> parents: 
60diff
changeset | 75 export LANG="en_US.UTF-8" | 
| 461 | 76 export LC_CTYPE="en_US.UTF-8" | 
| 355 | 77 # The en_US.UTF-8 causes weird sorting. | 
| 78 # (not really, but I prefer C based sort.) | |
| 414 | 79 export LC_COLLATE=C | 
| 413 
fda660f86df3
Don't set lc_messages to utf-8. Just use plain C.
 Edho Arief <edho@myconan.net> parents: 
407diff
changeset | 80 export LC_MESSAGES=C | 
| 267 
e35a36bb832e
Always export LSCOLORS and CLICOLOR
 Edho Arief <edho@myconan.net> parents: 
266diff
changeset | 81 export CLICOLOR= | 
| 342 
4a37643931c4
[rc/bashrc] Better color for solarized and general (blue -> cyan).
 Edho Arief <edho@myconan.net> parents: 
335diff
changeset | 82 export LSCOLORS="gxfxcxdxbxegedabagacad" | 
| 307 | 83 export LS_COLORS= | 
| 309 
592605e4d3bb
Use SI whenever possible. Use 1KiB instead otherwise.
 Edho Arief <edho@myconan.net> parents: 
308diff
changeset | 84 export BLOCKSIZE=1K | 
| 
592605e4d3bb
Use SI whenever possible. Use 1KiB instead otherwise.
 Edho Arief <edho@myconan.net> parents: 
308diff
changeset | 85 export BLOCK_SIZE=si | 
| 49 
b924652e169d
[bash] Various tweaks: prompt, unset for check variables, etc
 Edho Prima Arief <me@myconan.net> parents: 
48diff
changeset | 86 | 
| 62 | 87 alias ls="ls -F" | 
| 288 | 88 alias rd="rdesktop -g 1280x600 -K -a 15 -x m -z -P -r sound:off -r clipboard:CLIPBOARD -5" | 
| 593 | 89 alias man="LANG=C LC_ALL=C LC_CTYPE=C man" | 
| 477 | 90 alias be="bundle exec" | 
| 91 alias ll="ls -l" | |
| 92 alias la="ls -A" | |
| 53 
b9db5d89aae3
[bash] POSIX grep, GNU grep, standardized quote (" unless ' required).
 Edho Prima Arief <me@myconan.net> parents: 
52diff
changeset | 93 | 
| 43 | 94 _has_gnu_ls= | 
| 53 
b9db5d89aae3
[bash] POSIX grep, GNU grep, standardized quote (" unless ' required).
 Edho Prima Arief <me@myconan.net> parents: 
52diff
changeset | 95 _has_gnu_grep= | 
| 238 
5dcbf6ab0109
Prioritize gnuls over colorls on OpenBSD. Modified GNU ls alias to allow different executable name.
 Edho Arief <edho@myconan.net> parents: 
141diff
changeset | 96 _ls="ls" | 
| 270 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 97 _grep="grep" | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 98 _has_posix_grep=y | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 99 | 
| 506 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 100 if [ SunOS = "${_os}" ]; then | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 101 if [ -f /usr/share/lib/terminfo/s/screen ]; then | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 102 export TERMINFO=/usr/share/lib/terminfo | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 103 elif [ -f /opt/csw/share/terminfo/s/screen ]; then | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 104 export TERMINFO=/opt/csw/share/terminfo | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 105 else | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 106 unset TERMINFO | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 107 export TERM=dtterm | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 108 fi | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 109 | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 110 [ xterm = "${TERM}" ] && export TERM=xterm-256color | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 111 fi | 
| 
84ad2517ac90
Refactor terminal-relatd detection in sunos.
 edogawaconan <me@myconan.net> parents: 
501diff
changeset | 112 | 
| 501 | 113 case "${_os}" in | 
| 43 | 114 Linux) | 
| 115 _has_gnu_ls=y | |
| 96 
26c9dc482051
Merge. Linux obviously has gnu grep.
 Edho Prima Arief <edho@myconan.net> parents: 
75diff
changeset | 116 _has_gnu_grep=y | 
| 43 | 117 ;; | 
| 118 SunOS) | |
| 270 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 119 _has_posix_grep=n | 
| 43 | 120 [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y | 
| 53 
b9db5d89aae3
[bash] POSIX grep, GNU grep, standardized quote (" unless ' required).
 Edho Prima Arief <me@myconan.net> parents: 
52diff
changeset | 121 [ -x /usr/gnu/bin/grep ] && _has_gnu_grep=y | 
| 253 
e6de49d70fe7
(Not so) simplified solaris path add.
 Edho Arief <edho@myconan.net> parents: 
252diff
changeset | 122 # Higher priority directories | 
| 
e6de49d70fe7
(Not so) simplified solaris path add.
 Edho Arief <edho@myconan.net> parents: 
252diff
changeset | 123 for i in {/opt/csw,/usr/gnu}/{,s}bin; do | 
| 
e6de49d70fe7
(Not so) simplified solaris path add.
 Edho Arief <edho@myconan.net> parents: 
252diff
changeset | 124 [ -d "${i}" ] && PATH="${i}:${PATH}" | 
| 
e6de49d70fe7
(Not so) simplified solaris path add.
 Edho Arief <edho@myconan.net> parents: 
252diff
changeset | 125 done | 
| 
e6de49d70fe7
(Not so) simplified solaris path add.
 Edho Arief <edho@myconan.net> parents: 
252diff
changeset | 126 for i in /usr/{sfw,xpg4}/bin; do | 
| 
e6de49d70fe7
(Not so) simplified solaris path add.
 Edho Arief <edho@myconan.net> parents: 
252diff
changeset | 127 [ -d "${i}" ] && PATH="${PATH}:${i}" | 
| 
e6de49d70fe7
(Not so) simplified solaris path add.
 Edho Arief <edho@myconan.net> parents: 
252diff
changeset | 128 done | 
| 333 
aeb51856e281
[rc/bash] Solaris: additional path, removed useless test.
 Edho Arief <edho@myconan.net> parents: 
326diff
changeset | 129 [ -d "/opt/csw/gnu" ] && PATH="/opt/csw/gnu:${PATH}" | 
| 511 
ce21ebae61b4
Add /opt/local beforehand in sunos.
 edogawaconan <me@myconan.net> parents: 
510diff
changeset | 130 [ -d "/opt/local/sbin" ] && PATH="/opt/local/sbin:${PATH}" | 
| 
ce21ebae61b4
Add /opt/local beforehand in sunos.
 edogawaconan <me@myconan.net> parents: 
510diff
changeset | 131 [ -d "/opt/local/bin" ] && PATH="/opt/local/bin:${PATH}" | 
| 57 
ada5b9534765
[bash] Sanitize sunos ping.
 Edho Prima Arief <me@myconan.net> parents: 
56diff
changeset | 132 alias ping="ping -s" | 
| 
ada5b9534765
[bash] Sanitize sunos ping.
 Edho Prima Arief <me@myconan.net> parents: 
56diff
changeset | 133 alias ping6="ping -A inet6" | 
| 270 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 134 if command -v ggrep > /dev/null 2>&1; then | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 135 _has_gnu_grep=y | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 136 _grep="ggrep" | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 137 fi | 
| 272 | 138 if command -v gls > /dev/null 2>&1; then | 
| 139 _has_gnu_ls=y | |
| 140 _ls="gls" | |
| 141 fi | |
| 43 | 142 ;; | 
| 275 | 143 FreeBSD) | 
| 278 | 144 # Multi CPU awesomeness. | 
| 145 alias top="top -P" | |
| 453 
c3bfb45757e9
FreeBSD grep is GNU grep. Well, up to 9.x.
 Edho Arief <edho@myconan.net> parents: 
440diff
changeset | 146 # FreeBSD grep is GNU grep | 
| 
c3bfb45757e9
FreeBSD grep is GNU grep. Well, up to 9.x.
 Edho Arief <edho@myconan.net> parents: 
440diff
changeset | 147 _has_gnu_grep=y | 
| 275 | 148 ;; | 
| 62 | 149 OpenBSD) | 
| 407 
e5739479dc53
Prioritize colorls in openbsd.
 Edho Arief <edho@myconan.net> parents: 
403diff
changeset | 150 # GNU ls is broken in 5.2. Prioritize colorls instead. | 
| 
e5739479dc53
Prioritize colorls in openbsd.
 Edho Arief <edho@myconan.net> parents: 
403diff
changeset | 151 if command -v colorls > /dev/null 2>&1; then | 
| 
e5739479dc53
Prioritize colorls in openbsd.
 Edho Arief <edho@myconan.net> parents: 
403diff
changeset | 152 alias ls="colorls -F" | 
| 
e5739479dc53
Prioritize colorls in openbsd.
 Edho Arief <edho@myconan.net> parents: 
403diff
changeset | 153 elif command -v gls > /dev/null 2>&1; then | 
| 238 
5dcbf6ab0109
Prioritize gnuls over colorls on OpenBSD. Modified GNU ls alias to allow different executable name.
 Edho Arief <edho@myconan.net> parents: 
141diff
changeset | 154 _has_gnu_ls=y | 
| 
5dcbf6ab0109
Prioritize gnuls over colorls on OpenBSD. Modified GNU ls alias to allow different executable name.
 Edho Arief <edho@myconan.net> parents: 
141diff
changeset | 155 _ls="gls" | 
| 62 | 156 fi | 
| 157 ;; | |
| 351 
001cdf389aaf
NetBSD and DFBSD use similar package directory structure (pkgsrc).
 Edho Arief <edho@myconan.net> parents: 
345diff
changeset | 158 NetBSD|DragonFly) | 
| 249 | 159 if command -v gls > /dev/null 2>&1; then | 
| 160 _has_gnu_ls=y | |
| 161 _ls="gls" | |
| 162 elif command -v colorls > /dev/null 2>&1; then | |
| 276 | 163 alias ls="colorls -F" | 
| 249 | 164 fi | 
| 367 
37e422bb903b
Grep in color for NetBSD/DragonFly.
 Edho Arief <edho@myconan.net> parents: 
366diff
changeset | 165 alias grep='grep --color=auto' | 
| 249 | 166 ;; | 
| 67 | 167 CYGWIN*) | 
| 168 export PATH="${PATH}:${_org_path}" | |
| 169 ;; | |
| 581 | 170 MSYS_NT-*) | 
| 171 _has_gnu_ls=y | |
| 172 export PATH="${PATH}:${_org_path}" | |
| 173 ;; | |
| 43 | 174 esac | 
| 175 | |
| 314 | 176 if [ "${_has_gnu_ls}" = y ]; then | 
| 177 alias ls="${_ls} -F --color=auto" | |
| 516 
6ef4bbc171eb
Revert to default LS_COLORS. From ubuntu 14.04.
 edogawaconan <me@myconan.net> parents: 
514diff
changeset | 178 LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:'; | 
| 314 | 179 export LS_COLORS | 
| 180 fi | |
| 270 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 181 if [ "${_has_gnu_grep}" = y ]; then | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 182 alias grep="${_grep} --color=auto" | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 183 _has_posix_grep=y | 
| 523 
b88f621b6bd8
Add always-colored grep aliases.
 edogawaconan <me@myconan.net> parents: 
521diff
changeset | 184 | 
| 
b88f621b6bd8
Add always-colored grep aliases.
 edogawaconan <me@myconan.net> parents: 
521diff
changeset | 185 alias cgrep="${_grep} --color=always" | 
| 
b88f621b6bd8
Add always-colored grep aliases.
 edogawaconan <me@myconan.net> parents: 
521diff
changeset | 186 alias cegrep="cgrep -E" | 
| 
b88f621b6bd8
Add always-colored grep aliases.
 edogawaconan <me@myconan.net> parents: 
521diff
changeset | 187 alias cfgrep="cgrep -F" | 
| 270 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 188 fi | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 189 if [ "${_has_posix_grep}" = y ]; then | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 190 alias fgrep="grep -F" | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 191 alias egrep="grep -E" | 
| 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 192 fi | 
| 53 
b9db5d89aae3
[bash] POSIX grep, GNU grep, standardized quote (" unless ' required).
 Edho Prima Arief <me@myconan.net> parents: 
52diff
changeset | 193 | 
| 524 | 194 # FIXME: missing test for hg and xargs -0 | 
| 195 _xargs_grep="${_grep}" | |
| 196 [ "${_has_gnu_grep}" = y ] && _xargs_grep="${_grep} --color=always" | |
| 197 alias hggrep="hg locate -0 | xargs -0 ${_xargs_grep}" | |
| 198 unset _xargs_grep | |
| 199 | |
| 49 
b924652e169d
[bash] Various tweaks: prompt, unset for check variables, etc
 Edho Prima Arief <me@myconan.net> parents: 
48diff
changeset | 200 unset _has_gnu_ls | 
| 58 | 201 unset _has_gnu_grep | 
| 270 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 202 unset _has_posix_grep | 
| 238 
5dcbf6ab0109
Prioritize gnuls over colorls on OpenBSD. Modified GNU ls alias to allow different executable name.
 Edho Arief <edho@myconan.net> parents: 
141diff
changeset | 203 unset _ls | 
| 270 
0e41725e7d38
Grep, GNU Grep, Solaris Grep, etc.
 Edho Arief <edho@myconan.net> parents: 
269diff
changeset | 204 unset _grep | 
| 49 
b924652e169d
[bash] Various tweaks: prompt, unset for check variables, etc
 Edho Prima Arief <me@myconan.net> parents: 
48diff
changeset | 205 | 
| 261 | 206 # Custom application I usually install and safe to prioritize | 
| 573 | 207 for i in {"${HOME}/apps","/opt"{,"/${USER:-$LOGNAME}"}}/{tmux,ruby19,python26,node,tarsnap,symon,nginx,p7zip,composer}/{bin,sbin}; do | 
| 261 | 208 [ -d "${i}" ] && PATH="${i}:${PATH}" | 
| 209 done | |
| 304 | 210 # New(?) rubygems bin PATH | 
| 543 | 211 for i in {"${HOME}/apps","/opt"{,"/${USER:-$LOGNAME}"}}/ruby19/lib/ruby/gems/1.9.1/bin; do | 
| 304 | 212 [ -d "${i}" ] && PATH="${i}:${PATH}" | 
| 213 done | |
| 261 | 214 | 
| 264 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 215 # MySQL in common locations highest priority since new = better. Also no compatibility problem. | 
| 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 216 # Cluster is superset of Enterprise/GPL so it gets highest priority. | 
| 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 217 # And use only one. | 
| 543 | 218 for mydir in {"${HOME}",/apps,/opt}/mysql/{{cluster,enterprise}/mysql/,}bin; do | 
| 264 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 219 if [ -d "${mydir}" ]; then | 
| 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 220 PATH="${mydir}:${PATH}" | 
| 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 221 break | 
| 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 222 fi | 
| 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 223 done | 
| 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 224 | 
| 261 | 225 # Mercurial is optional since it will be inconsistent with ssh ... hg if this one gets priority. | 
| 264 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 226 # And use only one. | 
| 543 | 227 for hgdir in {"${HOME}/apps","/opt"}/mercurial{,/bin}; do | 
| 281 
87ce8cfdb8d4
Alias for newer hg. Also more search path.
 Edho Arief <edho@myconan.net> parents: 
279diff
changeset | 228 hgbin="${hgdir}/hg" | 
| 
87ce8cfdb8d4
Alias for newer hg. Also more search path.
 Edho Arief <edho@myconan.net> parents: 
279diff
changeset | 229 if [ -x "${hgbin}" ]; then | 
| 264 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 230 PATH="${PATH}:${hgdir}" | 
| 281 
87ce8cfdb8d4
Alias for newer hg. Also more search path.
 Edho Arief <edho@myconan.net> parents: 
279diff
changeset | 231 alias nhg="${hgbin}" | 
| 264 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 232 break | 
| 
c6c322c57e0e
Paths for MySQL, instabreak for mercurial.
 Edho Arief <edho@myconan.net> parents: 
262diff
changeset | 233 fi | 
| 261 | 234 done | 
| 56 
9343fa4dfd91
[bash] we have vim. Probably.
 Edho Prima Arief <me@myconan.net> parents: 
55diff
changeset | 235 | 
| 543 | 236 for supbindir in {"${HOME}/apps","/opt"}/supervisor{,d}/bin; do | 
| 273 
cf23a637f3a5
Supervisor support. Added on last since I usually install it in virtualenv
 Edho Arief <edho@myconan.net> parents: 
271diff
changeset | 237 if [ -d "${supbindir}" ]; then | 
| 
cf23a637f3a5
Supervisor support. Added on last since I usually install it in virtualenv
 Edho Arief <edho@myconan.net> parents: 
271diff
changeset | 238 PATH="${PATH}:${supbindir}" | 
| 
cf23a637f3a5
Supervisor support. Added on last since I usually install it in virtualenv
 Edho Arief <edho@myconan.net> parents: 
271diff
changeset | 239 break | 
| 
cf23a637f3a5
Supervisor support. Added on last since I usually install it in virtualenv
 Edho Arief <edho@myconan.net> parents: 
271diff
changeset | 240 fi | 
| 
cf23a637f3a5
Supervisor support. Added on last since I usually install it in virtualenv
 Edho Arief <edho@myconan.net> parents: 
271diff
changeset | 241 done | 
| 
cf23a637f3a5
Supervisor support. Added on last since I usually install it in virtualenv
 Edho Arief <edho@myconan.net> parents: 
271diff
changeset | 242 | 
| 436 
d6ac822569c4
Updated the uncolored prompt style.
 Edho Arief <edho@myconan.net> parents: 
435diff
changeset | 243 PS1='\u@\h:\w\$ ' | 
| 59 | 244 case "${TERM}" in | 
| 254 
dde04581a2bf
Combined PS1 and PROMPT_COMMAND conditional.
 Edho Arief <edho@myconan.net> parents: 
253diff
changeset | 245 xterm*|screen*|dtterm*) | 
| 584 
4130d41c6acb
Support for msys' USERNAME variable
 nanaya <me@myconan.net> parents: 
582diff
changeset | 246 PROMPT_COMMAND='echo -ne "\033]0;'"${USER:-${LOGNAME:-$USERNAME}}@$(uname -n)"': ${PWD}\007";'"${PROMPT_COMMAND}" | 
| 530 | 247 if [ "$(id -u)" = "0" ]; then | 
| 248 PS1='\[\e[1;31m\]\u@\h:\w\$\[\e[0m\] ' | |
| 249 elif [ "$(uname)" != "DragonFly" ]; then | |
| 250 # DragonFly's Bash is a bit buggy. | |
| 435 
4a71d0b1a4c6
Different, more compact style of prompt.
 Edho Arief <edho@myconan.net> parents: 
434diff
changeset | 251 PS1='\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\]:\[\e[0;36m\]\w\[\e[0m\]\$ ' | 
| 352 
038c28c748d0
The color prompt is broken-ish in DFBSD.
 Edho Arief <edho@myconan.net> parents: 
351diff
changeset | 252 fi | 
| 59 | 253 ;; | 
| 254 esac | |
| 255 | |
| 501 | 256 # Priority PATHs. Always enable. | 
| 533 
77c1f9e624a3
Rename prefix to `.ec.` instead of `.ecos_`.
 edogawaconan <me@myconan.net> parents: 
530diff
changeset | 257 PATH="${HOME}/bin:${HOME}/.ec.bin:/opt/local/bin:/opt/local/sbin:${PATH}" | 
| 501 | 258 | 
| 63 
b7814634220a
[bash] branch merge, added EDITOR change to vim when detected.
 Edho Prima Arief <me@myconan.net> parents: 
62diff
changeset | 259 if command -v vim > /dev/null 2>&1; then | 
| 
b7814634220a
[bash] branch merge, added EDITOR change to vim when detected.
 Edho Prima Arief <me@myconan.net> parents: 
62diff
changeset | 260 alias vi=vim | 
| 
b7814634220a
[bash] branch merge, added EDITOR change to vim when detected.
 Edho Prima Arief <me@myconan.net> parents: 
62diff
changeset | 261 export EDITOR=vim | 
| 
b7814634220a
[bash] branch merge, added EDITOR change to vim when detected.
 Edho Prima Arief <me@myconan.net> parents: 
62diff
changeset | 262 fi | 
| 266 | 263 | 
| 296 | 264 if command -v less > /dev/null 2>&1; then | 
| 395 
c01d272af466
Moved less configuration declaration to environment variable.
 Edho Arief <edho@myconan.net> parents: 
360diff
changeset | 265 export PAGER=less | 
| 488 
e3648f0482e5
Automatically exit less when the file is less than one screenful.
 edogawaconan <me@myconan.net> parents: 
477diff
changeset | 266 export LESS=-FMRXginsz-2 | 
| 296 | 267 fi | 
| 268 | |
| 365 | 269 # Test if we have GNU rm prefixed by g (esp if on non-GNU system). | 
| 270 # Usually on old Solaris and {Net,Open,DragonFly}BSD. | |
| 271 if command -v grm > /dev/null 2>&1; then | |
| 272 _rm="grm" | |
| 273 else | |
| 274 _rm="rm" | |
| 275 fi | |
| 276 # Test if the specified rm has "-I" parameter since it's much better. | |
| 277 if "${_rm}" -If "/tmp/.nonexistent.$(date '+%Y%m%d%H%M%S')" 2> /dev/null; then | |
| 278 alias rm="${_rm} -I" | |
| 279 else | |
| 280 alias rm="${_rm} -i" | |
| 281 fi | |
| 366 | 282 unset _rm | 
| 266 | 283 | 
| 402 
a23b0f6ee8a2
Add alias for zeropaste posting.
 Edho Arief <edho@myconan.net> parents: 
400diff
changeset | 284 if command -v curl > /dev/null 2>&1; then | 
| 658 | 285 alias 0p="gzip | curl 'https://0paste.com/pastes.txt' -F 'paste[paste_gzip]=@-'" | 
| 286 alias 0pp="gzip | curl 'https://0paste.com/pastes.txt' -F 'paste[is_private]=1' -F 'paste[paste_gzip]=@-'" | |
| 402 
a23b0f6ee8a2
Add alias for zeropaste posting.
 Edho Arief <edho@myconan.net> parents: 
400diff
changeset | 287 fi | 
| 
a23b0f6ee8a2
Add alias for zeropaste posting.
 Edho Arief <edho@myconan.net> parents: 
400diff
changeset | 288 | 
| 501 | 289 if command -v tmux > /dev/null 2>&1; then | 
| 290 case "${_os}" in | |
| 291 OpenBSD) | |
| 628 | 292 case "${_os_r}" in | 
| 293 6.[5-9]|[7-9].[0-9]|[1-9][0-9][0-9]*.[0-9]) | |
| 294 _tmux_conf_ver=2.9 | |
| 295 ;; | |
| 296 *) | |
| 297 # probably not accurate enough but I don't want to dig through all the previous versions. | |
| 298 _tmux_conf_ver=2.2 | |
| 299 ;; | |
| 300 esac | |
| 501 | 301 ;; | 
| 302 *) | |
| 514 
13deb0e1a2cc
tmux 1.3 doesn't have -V parameter.
 edogawaconan <me@myconan.net> parents: 
511diff
changeset | 303 case "$(tmux -V 2> /dev/null)" in | 
| 653 | 304 "tmux 2.9"|"tmux 2.9"[a-z]|"tmux "[3-9].[0-9]|"tmux "[3-9].[0-9][a-z]|"tmux "[1-9][0-9].[0-9]|"tmux "[1-9][0-9].[0-9][a-z]) _tmux_conf_ver=2.9;; | 
| 627 | 305 "tmux 2."[2-8]) _tmux_conf_ver=2.2;; | 
| 591 
23e326f74bfd
tmux point version only goes up to 9
 nanaya <me@myconan.net> parents: 
590diff
changeset | 306 "tmux 1.9"|"tmux 2."[0-1]) _tmux_conf_ver=1.9;; | 
| 559 | 307 "tmux 1."[4-8]) _tmux_conf_ver=1.4;; | 
| 501 | 308 *) _tmux_conf_ver=1.3;; | 
| 309 esac | |
| 310 ;; | |
| 311 esac | |
| 312 alias tmux="tmux -f '""${HOME}""/.tmux-""${_tmux_conf_ver}"".conf'" | |
| 313 unset _tmux_conf_ver | |
| 314 fi | |
| 315 | |
| 316 unset _os | |
| 628 | 317 unset _os_r | 
| 464 | 318 | 
| 654 | 319 # reset cursor shape | 
| 320 # reference: https://conemu.github.io/en/AnsiEscapeCodes.html#Terminal_modes | |
| 321 printf '\033[2 q' | |
| 322 | |
| 533 
77c1f9e624a3
Rename prefix to `.ec.` instead of `.ecos_`.
 edogawaconan <me@myconan.net> parents: 
530diff
changeset | 323 [ -f "${HOME}/.ec.bash.after" ] && . "${HOME}/.ec.bash.after" | 
