Repository navigation
Expand file tree
/
Copy pathbashrc
More file actions
130 lines (95 loc) · 3.69 KB
/
Copy pathbashrc
File metadata and controls
130 lines (95 loc) · 3.69 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# if not running interactively, don't do anything
[ -z "$PS1" ] && return
test "$DEBUG" && echo "[bashrc] Initializing..."
# --== environment ==--
# Note: A non-login bash gets nothing from ~/.bash_profile.
source "$DOTFILES"/lib/env.sh
# --== terminal multiplexer ==--
test "$DEBUG" && echo "[bashrc] Configuring terminal multiplexer..."
# Note: The multiplexer below starts its server with this PATH,
# for the commands that server runs itself.
source "$DOTFILES"/lib/path.sh
# Note: This is sourced before lib/multiplexer.sh so that the tmux
# client sends EDITOR and VISUAL on attach (see update-environment in
# tmux/tmux.conf), for programs opening an editor in a new window.
source "$DOTFILES"/lib/editor.sh
source "$DOTFILES"/lib/multiplexer.sh
# --== miscellaneous early setup ==--
test "$DEBUG" && echo "[bashrc] Configuring miscellaneous things..."
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# path to Homebrew (if installed)
command -v brew >/dev/null && export BREW=$(brew --prefix)
# --== bash completion ==--
test "$DEBUG" && echo "[bashrc] Configuring bash completion..."
if [ -f /etc/bash_completion ]; then
# Ubuntu Linux
. /etc/bash_completion
# NB: Workaround for environment variable expansion bug in bash 4.2+.
# See: http://askubuntu.com/q/41891
if ((BASH_VERSINFO[0] >= 4)) && \
((BASH_VERSINFO[1] >= 2)) && \
((BASH_VERSINFO[2] >= 29))
then
shopt -s direxpand
fi
fi
if [ -f "$BREW/etc/bash_completion" ]; then
# Mac OS X with Homebrew ("brew install bash-completion")
. "$BREW/etc/bash_completion"
fi
# --== git ==--
test "$DEBUG" && echo "[bashrc] Configuring git completion..."
# enable bash completion of git commands
if [ -f /etc/bash_completion.d/git-prompt ]; then
# newer Ubuntu Linux ("sudo aptitude install bash-completion")
. /etc/bash_completion.d/git-prompt # in case of no /etc/bash_completion
elif [ -f /etc/bash_completion.d/git ]; then
# older Ubuntu Linux ("sudo aptitude install bash-completion")
# or Cygwin ("apt-cyg install bash-completion")
. /etc/bash_completion.d/git # in case of no /etc/bash_completion
fi
# --== shell prompt ==--
test "$DEBUG" && echo "[bashrc] Configuring shell prompt..."
SHELL_PROMPT=': ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@${HOSTNAME}\[\033[00m\] \[\033[01;34m\]\w'
if [ "$(__git_ps1 x 2> /dev/null)" = "x" ]; then
# make shell prompt reflect current git status+branch
PS1="$SHELL_PROMPT"'\[\033[01;32m\]$(__git_ps1)\[\033[00m\]\n'
else
PS1="$SHELL_PROMPT"'\[\033[00m\]\n'
fi
# --== bash ==--
test "$DEBUG" && echo "[bashrc] Enabling bash vi mode..."
# use vi commands for advanced editing (hit ESC to enter command mode)
set -o vi
# --== shell plugins ==--
test "$DEBUG" && echo "[bashrc] Sourcing plugins..."
source "$DOTFILES"/lib/progress.sh
_plugins=("$DOTFILES"/plugins/*.sh "$DOTFILES"/plugins/*.bash)
_progress_init ${#_plugins[@]}
for f in "${_plugins[@]}"
do
_progress "plugin '${f##*/}'"
source "$f"
done
_progress_done
unset _plugins f
# --== fancier shell prompt! ==--
# Note: This replaces the prompt set above, where starship is installed;
# it comes after the plugins, keeping their PROMPT_COMMAND.
has starship && {
test "$DEBUG" && echo "[bashrc] Configuring starship prompt..."
eval "$(starship init bash)"
}
# --== local configuration ==--
# Local customized path and environment settings, etc.
if [ -f ~/.bash_local ]; then
test "$DEBUG" && echo "[bashrc] Sourcing ~/.bash_local..."
. ~/.bash_local
fi
test "$DEBUG" && echo "[bashrc] Done!"