updates
[dotfiles.git] / bashrc
CommitLineData
0e3df0c2 1
2# Bash won't get SIGWINCH if another process is in the foreground.
3# Enable checkwinsize so that bash will check the terminal size when
4# it regains control.
5# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
6shopt -s checkwinsize
7
8# Enable history appending instead of overwriting.
9shopt -s histappend
10
11case ${TERM} in
12 xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
13 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
14 ;;
15 screen)
16 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
17 ;;
18esac
19
20# fortune is a simple program that displays a pseudorandom message
21# from a database of quotations at logon and/or logout.
22# If you wish to use it, please install "fortune-mod" from the
23# official repositories, then uncomment the following line:
24
25[[ "$PS1" ]] && /usr/bin/fortune
26
27# Set colorful PS1 only on colorful terminals.
28# dircolors --print-database uses its own built-in database
29# instead of using /etc/DIR_COLORS. Try to use the external file
30# first to take advantage of user additions. Use internal bash
31# globbing instead of external grep binary.
32
33# sanitize TERM:
34safe_term=${TERM//[^[:alnum:]]/?}
35match_lhs=""
36
37[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
38[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
39[[ -z ${match_lhs} ]] \
40 && type -P dircolors >/dev/null \
41 && match_lhs=$(dircolors --print-database)
42
43if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then
44
45 # we have colors :-)
46
47 # Enable colors for ls, etc. Prefer ~/.dir_colors
48 if type -P dircolors >/dev/null ; then
49 if [[ -f ~/.dir_colors ]] ; then
50 eval $(dircolors -b ~/.dir_colors)
51 elif [[ -f /etc/DIR_COLORS ]] ; then
52 eval $(dircolors -b /etc/DIR_COLORS)
53 fi
54 fi
55
56 # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04
57 # PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -lah | grep -m 1 total | sed 's/total //')b\[\033[1;37m\])\342\224\200> \[\033[0m\]"
58
59 # new
60 PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\$([[ \$? != 0 ]] && echo \"\342\224\200(\[\033[0;31m\]\342\234\227\[\033[1;37m\])\")\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -sh | head -n1 | sed 's/total //')b\[\033[1;37m\])\342\224\200> \[\033[0m\]"
61
62
63 # Use this other PS1 string if you want \W for root and \w for all other users:
64 # PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "
65
66 alias ls="ls --color=auto"
67 alias dir="dir --color=auto"
68 alias grep="grep --color=auto"
69 alias dmesg='dmesg --color'
70 alias nano='nano -w'
71
72
73 man() {
74 env LESS_TERMCAP_mb=$'\E[01;31m' \
75 LESS_TERMCAP_md=$'\E[01;38;5;74m' \
76 LESS_TERMCAP_me=$'\E[0m' \
77 LESS_TERMCAP_se=$'\E[0m' \
78 LESS_TERMCAP_so=$'\E[38;5;246m' \
79 LESS_TERMCAP_ue=$'\E[0m' \
80 LESS_TERMCAP_us=$'\E[04;38;5;146m' \
81 man "$@"
82 }
83
84 # Uncomment the "Color" line in /etc/pacman.conf instead of uncommenting the following line...!
85
86 # alias pacman="pacman --color=auto"
87
88else
89
90 # show root@ when we do not have colors
91
92 # PS1="\u@\h \w \$([[ \$? != 0 ]] && echo \":( \")\$ "
93
94 PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\$([[ \$? != 0 ]] && echo \"\342\224\200(\[\033[0;31m\]\342\234\227\[\033[1;37m\])\")\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -sh | head -n1 | sed 's/total //')b\[\033[1;37m\])\342\224\200> \[\033[0m\]"
95
96 # Use this other PS1 string if you want \W for root and \w for all other users:
97 # PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] && echo \":( \")\$ "
98
99fi
100
101PS2="> "
102PS3="> "
103PS4="+ "
104
105# Try to keep environment pollution down, EPA loves us.
106unset safe_term match_lhs
107
108# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).
109[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
110
111# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).
112# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook
113[ -r /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash
114
115# muh aliases
116alias grep='grep --color=auto'
117alias ls='ls --color=auto'
118alias aurget='yaourt -Sa'
119alias kremget='yaourt -Sa'
120alias kremrem='sudo pacman -Rsc'
121alias kremlook='sudo pacman -Qq'
122alias kremupdate='sudo pacman -Syu'
123alias kremwho='pacman -Qo'
124
125PATH="${PATH}:/home/kremlin/bin"
126
127# color less
128export LESS=-R
129export LESS_TERMCAP_me=$(printf '\e[0m')
130export LESS_TERMCAP_se=$(printf '\e[0m')
131export LESS_TERMCAP_ue=$(printf '\e[0m')
132export LESS_TERMCAP_mb=$(printf '\e[1;32m')
133export LESS_TERMCAP_md=$(printf '\e[1;34m')
134export LESS_TERMCAP_us=$(printf '\e[1;32m')
135export LESS_TERMCAP_so=$(printf '\e[1;44;1m')