-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_profile
142 lines (125 loc) · 3.79 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
#if not running interactively, dont do anything
[ -z "$PS1" ] && return
#function to check if program is in path
has() { type -p "$1" >/dev/null; }
#add a directory to path
appendPath() { if [ -d "$1" ] ; then PATH="$PATH:$1"; fi }
prependPath() { if [ -d "$1" ] ; then PATH="$1:$PATH"; fi }
#add a brew directory to path
brewPath() { prependPath "$prefix$1"; }
#Notify if PATH is already set
if [ -n "$PATH" ] ; then
#if set, replace it
printf '\033[31mWARNING: reset path from %s \033[39m\n' "$PATH"
export PATH=""
fi
#Set Base PATH
basePaths=(
"$HOME/bin"
"/usr/local/bin"
"/usr/bin"
"/usr/sbin"
"/sbin"
"/data/data/com.termux/files/usr/bin"
"/bin"
"$HOME/.cargo/bin"
"$HOME/.local/bin"
"$HOME/scoop/shims"
"/c/WINDOWS/System32/WindowsPowershell/v1.0"
"/c/WINDOWS"
"/c/WINDOWS/System32"
"opt/X11/bin"
"/Applications/Firefox.app/Contents/MacOS"
"/Applications/Discord.app/Contents/MacOS"
"/Applications/Wireshark.app/Contents/MacOS"
)
for i in "${basePaths[@]}" ; do
case "$i" in
"/bin")
#set PATH so it includes homebrew bins if they exists, otherwise add /bin
if [ -f "/opt/homebrew/bin/brew" ] ; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [ -f "/usr/local/bin/brew" ] ; then
eval "$(/usr/local/bin/brew shellenv)"
elif [ -z "$TERMUX_VERSION" ] ; then
appendPath "/bin"
fi ;;
*)
appendPath "$i" ;;
esac
done
#Set PATH So it includes individual brew app bins
if has brew ; then
prefix="$(brew --prefix)"
brewPaths=(
#Add editors to the end
"/opt/ed/libexec/gnubin"
"/opt/gnu-sed/libexec/gnubin"
#Add Basic Utils
"/opt/bison/bin"
"/opt/man-db/libexec/bin"
#Add languages next
"/opt/gawk/libexec/gnubin"
"/opt/ruby/bin"
"/opt/[email protected]/bin"
"/opt/[email protected]/libexec/bin"
"/opt/openjdk@17/bin"
#Add archive tools
"/opt/zip/bin"
"/opt/unzip/bin"
"/opt/gnu-tar/libexec/gnubin"
"/opt/pax/bin"
#Add basic utilities finally
"/opt/llvm/bin"
"/opt/curl/bin"
"/opt/m4/bin"
"/opt/findutils/libexec/gnubin"
"/opt/binutils/bin"
"/opt/gnu-which/libexec/gnubin"
"/opt/gnu-time/libexec/gnubin"
"/opt/ncurses/bin"
"/opt/make/libexec/gnubin"
"/opt/grep/libexec/gnubin"
"/opt/util-linux/bin"
"/opt/coreutils/libexec/gnubin"
)
for i in "${brewPaths[@]}" ; do
brewPath "$i"
done
#load brew bash completion script
[[ -r "$prefix/etc/profile.d/bash_completion.sh" ]] && . "$prefix/etc/profile.d/bash_completion.sh"
fi
#Export env variables
export PATH="$PATH"
if [ "$COLUMNS" -gt 70 ] ; then
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
# (for zsh) export PS1="%B%F{green}%n%f%b%B%F{green}@%f%b%B%F{green}%m%f%b:%F{blue}%~%f$ "
else
export PS1="\[\e[0;32m\]\w\[\e[0m\] \[\e[0;97m\]\$\[\e[0m\] "
fi
export MANPATH
if has vim ; then
EDITOR=$(command -v "vim")
elif has nano ; then
EDITOR=$(command -v "nano")
fi
if [ "$(has arch && arch)" = "i386" ] ; then
export BASH_SILENCE_DEPRECATION_WARNING=1
fi
export EDITOR
has java && export CPPFLAGS="-I$prefix/opt/openjdk@17/include"
#Source remaining files
if has dircolors ; then
eval "$(dircolors "$HOME/.dir_colors")"
fi
bind 'set mark-symlinked-directories on' #put a slash at the end of symlinked directories (cuz dropbox)
if [ -f "$HOME/.bash_aliases" ] ; then
source "$HOME/.bash_aliases"
fi
if [ -f "$HOME/.osspecific" ] ; then
source "$HOME/.osspecific"
fi
if [ -f "$HOME/.launchscripts" ] ; then
source "$HOME/.launchscripts"
fi