-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_profile
127 lines (100 loc) · 3.33 KB
/
.bash_profile
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
# Read this when bash is initialized as a login shell
[ -f ~/.bashrc ] && source ~/.bashrc
function colorize {
local COLORS=( BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE )
if [ ! "$1" ]
then echo
echo "usage: $0 'STRING' COLOR BOLD"
echo
echo ' STRING the string to colorize'
echo -n ' COLOR name of color to use ( '
echo -n $COLORS
echo ' )'
echo ' BOLD boolean signifies whether to bold or not'
echo
echo 'ex. colorize "string is a test\n" GREEN 1'
echo
exit 1
fi
local STRING="$1" COLOR="$2" BOLD="$3"
local COLORS=( BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE )
local CC="\e[0m" # Default no color
local INDEX=0;
if [ $BOLD != 0 ]; then BOLD=1; else BOLD=0; fi
for C in "${COLORS[@]}"; do
if [ "$C" == "$COLOR" ]; then
local CC="\e[$BOLD;$((30 + $INDEX))m"
echo -en "$CC$STRING\e[m"
return;
fi
INDEX=$(($INDEX+1))
done
echo -n "$CC$STRING\e[m"
}
function parse_git_branch {
local BRANCH ERRCODE
BRANCH=$(git symbolic-ref HEAD 2> /dev/null) || return
BRANCH=${BRANCH#refs/heads/}
local GITPROMPT=$BRANCH
# Staged changes but not committed
`git diff --cached --quiet 2>/dev/null >&2`; ERRCODE=$?;
if [ $ERRCODE -eq 1 ]
then
GITPROMPT=$GITPROMPT'|'$(colorize 'staged' 'RED' 0)
fi
# Changes not added and not committed
`git diff-files --quiet 2>/dev/null >&2`; ERRCODE=$?;
if [ $ERRCODE -eq 1 ]
then
GITPROMPT=$GITPROMPT'|'$(colorize 'unstaged' 'RED' 0)
fi
# Files not added, untracked and not in .gitignore
`git ls-files --exclude-standard --others --error-unmatch . 2>/dev/null >&2`; ERRCODE=$?;
if [ $ERRCODE -eq 0 ]
then
GITPROMPT=$GITPROMPT'|'$(colorize 'untracked' 'GREEN' 0)
fi
# All is well and clean
if [ "$GITPROMPT" = "$BRANCH" ]
then
GITPROMPT=$GITPROMPT'|'$(colorize "\xE2\x9C\x93" "GREEN" 1)
fi
echo -n "($GITPROMPT)"
}
function enable-git-prompt {
export PS1OLD="$PS1"
export PS1="$(colorize "\u@\h" "GREEN" 0) $(colorize "(\$(date +%H:%M))" "WHITE" 1) $(colorize "\w" "BLUE" 1) \$(parse_git_branch)\n\$ "
}
function disable-git-prompt {
export PS1GIT="$PS1"
export PS1="$PS1OLD"
}
# Path to the bash it configuration
#export BASH_IT="/Users/decal/bash-it"
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
# Generated by `npx --shell-auto-fallback` .. refer to npx(1)
command_not_found_handle() {
# Do not run within a pipe
if test ! -t 1; then
>&2 echo "command not found: $1"
return 127
fi
if which npx > /dev/null; then
echo "$1 not found. Trying with npx..." >&2
else
return 127
fi
if ! [[ $1 =~ @ ]]; then
npx --no-install "$@"
else
npx "$@"
fi
return $?
}
export PATH="/home/decal/.linuxbrew/bin:$PATH" â·································
export MANPATH="/home/decal/.linuxbrew/share/man:$MANPATH" â·································
export INFOPATH="/home/decal/.linuxbrew/share/info:$INFOPATH"