-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
105 lines (81 loc) · 2.33 KB
/
.bashrc
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
# if not running interactively, don't do anything
case $- in
*i*) ;;
*) return ;;
esac
# check and if necessary update window size after each command
shopt -s checkwinsize
# case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob
# append to the Bash history file, rather than overwriting it
shopt -s histappend
# autocorrect typos in path names when using `cd`
shopt -s cdspell
# `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux` (only bash 4)
shopt -s autocd
# recursive globbing, e.g. `echo **/*.txt` (only bash 4)
shopt -s globstar
# enable completion
if ! shopt -oq posix; then
if [[ -f /usr/share/bash-completion/bash_completion ]]; then
. /usr/share/bash-completion/bash_completion
elif [[ -f /etc/bash_completion ]]; then
. /etc/bash_completion
elif [[ -f /usr/local/etc/bash_completion ]]; then
. /usr/local/etc/bash_completion
fi
if [[ -d /etc/bash_completion.d/ ]]; then
for file in /etc/bash_completion.d/* ; do
source "$file"
done
unset file
fi
fi
# set prompt
prompt_git() {
local s='';
local branchName='';
# check if the current directory is in a Git repository.
if [ "$(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}")" == '0' ]; then
# get the short symbolic ref.
# if HEAD isn’t a symbolic ref, get the short SHA for the latest commit
# otherwise, just give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";
[ -n "${s}" ] && s=" [${s}]";
echo -e "${1}${branchName}${s}";
else
return;
fi;
}
if [ -f /run/.toolboxenv ]; then
PS1="📦[\u@\$CONTAINER_ID \W]\$ "
else
PS1="\\n\\u at \\h in \\w\$(prompt_git \" on \")\\n$ "
fi
# load exports
exports_file="$HOME/.exports"
if [[ -r $exports_file ]] && [[ -f $exports_file ]]; then
source $exports_file
fi
# load path
path_file="$HOME/.path"
if [[ -r $path_file ]] && [[ -f $path_file ]]; then
source $path_file
fi
# load aliases
aliases_file="$HOME/.aliases"
if [[ -r $aliases_file ]] && [[ -f $aliases_file ]]; then
source $aliases_file
fi
# load functions
functions_file="$HOME/.functions"
if [[ -r $functions_file ]] && [[ -f $functions_file ]]; then
source $functions_file
fi
# device specifics
device_file="$HOME/.device"
if [[ -r $device_file ]] && [[ -f $device_file ]]; then
source $device_file
fi