summaryrefslogtreecommitdiff
path: root/system/bash/bashrc
blob: 0f385e030f23b42dab7bf9b2bb0a351b38385f00 (plain) (blame)
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
# Welcome to Adélie Linux
# /etc/bash/bashrc - run by bash on every startup

# Prior to 1.0a3, we did a lot of heavy lifting here.
# Massive cleanup for 1.0a3 makes things faster and more efficient.

# No interactivity = no point
if [[ $- != *i* ]]; then
	return
fi

# Extra stat(3) call to invalidate hash cache.  Better UX, but lots of waste.
# shopt -s checkhash

# Handle window resizing after a curses program quits
shopt -s checkwinsize

# Append instead of overwriting histfile.
shopt -s histappend

# Allow users to correct typos in history substs.
shopt -s histreedit

# Save commands as they were typed.
shopt -s lithist

# Don't show every command available if a user types \t on a bare line
shopt -s no_empty_cmd_completion

# Expand things like \n \r \t when using built-in echo(1).
shopt -s xpg_echo


do_colour() {
	local colourise=false
	LS_COLORS=
	eval "$(dircolors -b)"
	if [[ -n ${LS_COLORS:+set} ]]; then
		colourise=true
	else
		unset LS_COLORS
	fi

	if ${colourise} ; then
		if [[ ${EUID} == 0 ]] ; then
			PS1='\[\e[01m\]\h\[\e[22m\] \[\e[01;36m\]\w\[\e[00m\] \[\e[01;31m\]\$\[\e[00m\] '
		else
			PS1='\u on \[\e[01m\]\h\[\e[22m\] \w \[\e[01;32m\]\$\[\e[00m\] '
		fi

		alias ls='ls --color=auto'
		alias grep='grep --colour=auto'
		alias egrep='egrep --colour=auto'
		alias fgrep='fgrep --colour=auto'
	else
		if [[ ${EUID} == 0 ]] ; then
			# show root@ when we don't have colors
			PS1='! \u on \h \w \$ '
		else
			PS1='\u on \h \w \$ '
		fi
	fi
}

do_colour

for sh in /etc/bash/bashrc.d/* ; do
	[[ -r ${sh} ]] && source "${sh}"
done

unset do_colour