-
Notifications
You must be signed in to change notification settings - Fork 0
/
shrc
91 lines (79 loc) · 2.13 KB
/
shrc
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
# tell vim to highlight with posix syntax: dash
# vim: set filetype=sh:
#
# Bash rc
#
case "$-" in
*i*) : ;; # interactive
*) return ;;
esac
#
# Must be an interactive shell
#
_sc_seen_profile()
{
if [ -n "$BASH_VERSION" ] ; then
echo "${BASH_SOURCE[@]}" | grep -s -q "$HOME/.profile"
return $?
fi
return 0
}
_sc_is_login_shell()
{
bshell=$(basename "${SHELL}")
cmd=$(ps -o comm= -p $$)
arg=$(echo "${cmd}" | egrep -w -- "-l|--login")
if [ "${cmd}" = "-${SHELL}" ] ||
[ "${cmd}" = "-${bshell}" ] ||
[ -n "${arg}" ] ||
_sc_seen_profile ; then
return 0
fi
return 1
}
# shell setup
set -o emacs
if [ -n "$BASH_VERSION" ] ; then
# tells bash to check the window size after each command
shopt -s checkwinsize
# tell bash to expand directories from environment vars during
# tab completion - this works around the annoying \$ escape bug
# references:
# https://askubuntu.com/questions/41891/bash-auto-complete-for-environment-variables/
# https://lists.gnu.org/archive/html/bug-bash/2011-02/msg00274.html
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=650626 (closed)
# https://bugs.launchpad.net/ubuntu/+source/bash/+bug/778627 (still open)
if shopt | grep -s -q direxpand ; then
shopt -s direxpand
fi
fi
# if TERM is not set, sort it out
if [ -z "$TERM" -o "$TERM" = "dumb" ] ; then
TERM="xterm" ; export TERM # lowest common denominator
fi
# look for the best "xterm" terminfo entry
if [ "$TERM" = "xterm" ] ; then
for info in xterm-256color xterm-debian ; do
if infocmp "${info}" > /dev/null 2>&1
then
TERM=${info} ; export TERM
break
fi
done
unset info
fi
# if [ -z "$TMUX" -a "$TERM" = "screen-256color" ] ; then
# stty erase ^h kill ^u
# fi
IS_LOGIN_SHELL=0
if _sc_is_login_shell ; then
IS_LOGIN_SHELL=1
SHLVL=1
fi
if [ -z "$BASH_VERSION" ] ; then
PS1=""
PS1="${PS1}${debian_chroot:+($debian_chroot)}"
PS1="${PS1}${USER}@${HOSTNAME:-$(hostname)}"
PS1="${PS1}($(basename $(ps -o comm= -p $$)))"
PS1="${PS1}:\$ "
fi