-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot.bashrc
109 lines (98 loc) · 2.41 KB
/
dot.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
# ~/.bashrc
#
# Use this file only for interactive shell
case "$-" in ( *i* ) ;; ( * ) return ;; esac
# Prevent from repeatedly sourcing from .profile
test -n "${_rcsourced}" && test -n "${_inprofile}" && return
# Determine shell
if test -n "${BASH_VERSION}" ; then
_sh=bash
elif test -n "${KSH_VERSION}" ; then
_sh=ksh93
elif test -n "${FCEDIT}" ; then
_sh=ksh
else
_sh=sh
fi
# Get operating system name
_os="$(uname -s)"
# Set some shell variables if not set
test -n "${UID}" || UID="$(id -ur)"
test -n "${EUID}" || EUID="$(id -u)"
test -n "${USER}" || USER="$(id -un)"
test -n "${HOST}" || HOST="$(hostname)"
# Set shell options
case "${_sh}" in
( ksh* )
set -o vi
set -o viraw
case "$(set -o)" in ( *multiline* ) set -o multiline ;; esac
;;
esac
# History options
HISTSIZE=1000
case "$(set -o)" in ( *histexpand* ) set -o histexpand ;; esac
case "${_sh}" in
( bash* )
shopt -s histappend
HISTCONTROL=ignoreboth
HISTTIMEFORMAT="%F %T %Z "
;;
esac
# Set timeout for root
if test "${EUID}" -eq 0 ; then
TMOUT=7200
fi
# Set prompt
case "${_sh}" in
( bash* )
PS1='[\A] \u@\h:\w\$ ' ;;
( ksh* )
PS1='${USER}@${HOST}:${PWD}> '
test "${_sh}" = "ksh93" && PS1="(\$(date +%H:%M)) ${PS1}"
;;
esac
# Colorize prompt
if test -n "${TERM}" && test -t 0 ; then
_off="$(tput sgr0 2>/dev/null)" # Turn off
_bold="$(tput bold 2>/dev/null)" # Bold
_colu="$(tput setaf 4 2>/dev/null)" # Blue
_colr="$(tput setaf 1 2>/dev/null)" # Red
if test -z "${_colu}" ; then
# setaf capability is not set, try setf instead
_colu="$(tput setf 1 2>/dev/null)" # Blue
_colr="$(tput setf 4 2>/dev/null)" # Red
fi
if test "${EUID}" -eq 0 ; then
# For root user
_on="${_bold}${_colr}"
else
# For ordinary user
case "${_os}" in
( AIX* ) _on="${_bold}" ;; # Only bold for AIX
( Linux* ) _on="${_bold}${_colu}" ;;
esac
fi
if test -n "${_on}" && test -n "${_off}" ; then
case "${_sh}" in
( bash* )
PS1="\[${_on}\]${PS1% }\[${_off}\] "
test -n "${PS2}" && PS2="\[${_on}\]${PS2% }\[${_off}\] "
;;
( ksh* )
PS1="${_on}${PS1% }${_off} "
test -n "${PS2}" && PS2="${_on}${PS2% }${_off} "
;;
esac
fi
unset _bold _colu _colr _on _off
fi
# Source aliases and functions if they exist
for _f in ${HOME}/.alias ${HOME}/.aliases ${HOME}/.functions ; do
test -f "${_f}" && . "${_f}" || true
done
unset _f
unset _sh _os
# Set sourced flag
_rcsourced="true"