-
Notifications
You must be signed in to change notification settings - Fork 2
/
bash_profile.sh
66 lines (54 loc) · 1.7 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
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# 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 ~/.git-completion.bash ] && source ~/.git-completion.bash
if type brew &>/dev/null; then
for COMPLETION in $(brew --prefix)/etc/bash_completion.d/*
do
[[ -f $COMPLETION ]] && source "$COMPLETION"
done
if [[ -f $(brew --prefix)/etc/profile.d/bash_completion.sh ]];
then
source "$(brew --prefix)/etc/profile.d/bash_completion.sh"
fi
fi
# Colorful prompt
if [ "$USER" = "root" ]
then
# PS1='\[\033[01;35m\]\h\[\033[01;34m\] \W #\[\033[00m\] '
PS1='\[\e[0;31m\][\u@\h \W]\$\[\e[0m\] '
elif [ -n "${SSH_CONNECTION}" ]
then
# PS1='\[\033[01;36m\]\h\[\033[01;34m\] \W #\[\033[00m\] '
PS1='\[\e[0;31m\][\u@\h \W]\$\[\e[0m\] '
else
# PS1='\[\033[01;32m\]\h\[\033[01;34m\] \W #\[\033[00m\] '
PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '
fi
# only set key bindings on interactive shell
if [ -n "$INTERACTIVE_BASH" ]
then
# fix delete key on macOS
[ "$MACOS" ] && bind '"\e[3~" delete-char'
fi