forked from MikeMcQuaid/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_profile.sh
54 lines (43 loc) · 1.44 KB
/
bash_profile.sh
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
# load shared shell configuration
source ~/.shprofile
# check if this is a login and/or interactive shell
[ "$0" = "-bash" ] && export LOGIN_BASH="1"
echo "$-" | grep -q "i" && export INTERACTIVE_BASH="1"
# run bashrc if this is a login, interactive shell
if [ -n "$LOGIN_BASH" ] && [ -n "$INTERACTIVE_BASH" ]
then
source ~/.bashrc
fi
# Set HOST for ZSH compatibility
export HOST=$HOSTNAME
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Enable history appending instead of overwriting.
shopt -s histappend
# Save multiline commands
shopt -s cmdhist
# Correct minor directory changing spelling mistakes
shopt -s cdspell
# Bash completion
[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion
[ -f "$HOMEBREW_PREFIX/etc/bash_completion" ] && source "$HOMEBREW_PREFIX/etc/bash_completion" >/dev/null
# Colorful prompt
if [ "$USER" = "root" ]
then
PS1='\[\033[01;35m\]\h\[\033[01;34m\] \W #\[\033[00m\] '
elif [ -n "${SSH_CONNECTION}" ]
then
PS1='\[\033[01;36m\]\h\[\033[01;34m\] \W #\[\033[00m\] '
else
PS1='\[\033[01;32m\]\h\[\033[01;34m\] \W #\[\033[00m\] '
fi
# only set key bindings on interactive shell
if [ -n "$INTERACTIVE_BASH" ]
then
# fix delete key on macOS
[ "$MACOS" ] && bind '"\e[3~" delete-char'
# alternate mappings for Ctrl-U/V to search the history
bind '"^u" history-search-backward'
bind '"^v" history-search-forward'
fi