-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbash-profile
executable file
·250 lines (181 loc) · 5.08 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/bash
# shell ////////////////////////////////////////////////////////////////////////
# loading order - login shell:
# system profile
# system bash configuration
# home bash configuration
# loading order - non-login shell:
# system bash configuration
# home bash configuration
# non-login shell requires 'bashrc'
# profile /////////////////////////////////////////////////////////////////////
if [ -n "${TERMUX_VERSION}" ]
then
frobulator.fwd "Loading profile..."
echo
frobulator.clear
fi
# bash /////////////////////////////////////////////////////////////////////////
if [ -n "${BASH_VERSION}" ]
then
# aliases //////////////////////////////////////////////////////////////////
if [ -d "${HOME}"/.bash-aliases ]
then
for alias in "${HOME}"/.bash-aliases/*
do
if [ -x "${alias}" ]
then
. "${alias}"
fi
done
fi
if [ -f "${HOME}"/.bash_aliases ]
then
. "${HOME}"/.bash_aliases
fi
# functions ////////////////////////////////////////////////////////////////
if [ -d "${HOME}"/.bash-functions ]
then
for function in "${HOME}"/.bash-functions/*
do
if [ -x "${function}" ]
then
. "${function}"
fi
done
fi
if [ -f "${HOME}"/.bash_functions ]
then
. "${HOME}"/.bash_functions
fi
fi
# path /////////////////////////////////////////////////////////////////////////
PATH=""
# container
[ -d /usr/local/sbin ] && PATH+="/usr/local/sbin:"
[ -d /usr/local/bin ] && PATH+="/usr/local/bin:"
[ -d /usr/sbin ] && PATH+="/usr/sbin:"
[ -d /usr/bin ] && PATH+="/usr/bin:"
[ -d /sbin ] && PATH+="/sbin:"
[ -d /bin ] && PATH+="/bin:"
# termux
[ -d "${HOME}"/.local/sbin ] && PATH+="${HOME}/.local/sbin:"
[ -d "${HOME}"/.local/bin ] && PATH+="${HOME}/.local/bin:"
[ -d "${HOME}"/.sbin ] && PATH+="${HOME}/.sbin:"
[ -d "${HOME}"/.bin ] && PATH+="${HOME}/.bin:"
[ -d "${PREFIX}"/sbin ] && PATH+="${PREFIX}/sbin:"
[ -d "${PREFIX}"/bin ] && PATH+="${PREFIX}/bin:"
# android
[ -d /system/sbin ] && PATH+="/system/sbin:"
[ -d /system/bin ] && PATH+="/system/bin:"
PATH="${PATH}"
# user ////////////////////////////////////////////////////////////////////////
if [ -n "${TERMUX_VERSION}" ]
then
if [ -z "${USER}" ]
then
USER="termux"
fi
fi
# colors ///////////////////////////////////////////////////////////////////////
black="\001$(tput setaf 0)\002"
red="\001$(tput setaf 1)\002"
green="\001$(tput setaf 2)\002"
yellow="\001$(tput setaf 3)\002"
blue="\001$(tput setaf 4)\002"
magenta="\001$(tput setaf 5)\002"
cyan="\001$(tput setaf 6)\002"
white="\001$(tput setaf 7)\002"
reset="\001$(tput sgr 0)\002"
# prompt ///////////////////////////////////////////////////////////////////////
unset PS1
if [[ $(id -u -n) = "root" ]]
then
prompt_color="${red}"
elif [[ $(pidof proot) ]]
then
prompt_color="${magenta}"
else
prompt_color="${green}"
fi
PS1+="${reset}[ "
PS1+="${prompt_color}${USER}"
PS1+="${reset} ]"
if [[ $(id -u -n) = "root" ]]
then
PS1+="${white} >_ # ${reset}"
else
PS1+="${white} >_ $ ${reset}"
fi
unset prompt_color
# display //////////////////////////////////////////////////////////////////////
if [ -n "${TERMUX_VERSION}" ]
then
TERMUX_X11_APPLICATION="com.termux.x11"
TERMUX_X11_SERVER="termux-x11"
TERMUX_X11_DRIVER="virpipe"
TERMUX_X11_ACCELERATOR="virgl_test_server"
if [ -z "${DISPLAY}" ]
then
DISPLAY=":0"
fi
if [[ $(pgrep -f "${TERMUX_X11_ACCELERATOR}") ]]
then
:
else
"${TERMUX_X11_ACCELERATOR}" &
fi
if [[ $(pgrep -f "${TERMUX_X11_APPLICATION}") ]]
then
:
else
"${TERMUX_X11_SERVER}" "${DISPLAY}" &
fi
# export variables
export DISPLAY="${DISPLAY}"
export TERMUX_X11_APPLICATION="${TERMUX_X11_APPLICATION}"
export TERMUX_X11_SERVER="${TERMUX_X11_SERVER}"
export TERMUX_X11_DRIVER="${TERMUX_X11_DRIVER}"
export TERMUX_X11_ACCELERATOR="${TERMUX_X11_ACCELERATOR}"
fi
# dextop ///////////////////////////////////////////////////////////////////////
if [ -n "${TERMUX_VERSION}" ]
then
# get session login count
ticker=$(cat "${HOME}"/.dextop/dextop-ticker)
session_title="termux"
# load welcome message
if [[ $(pgrep -f proot) ]]
then
session_tilte="${distribution}"
fi
session_title="${session_title^}"
frobulator.fwd "Login ${ticker} >>> Welcome to Dextop" "[ ${session_title} ]"
echo
frobulator.inf "Graphical session:"
frobulator.nul "'container-session -o | -x | -u [User Name] | -d [Directory] | -f [Application]'"
echo
frobulator.inf "Update utilities:"
frobulator.nul "'dextop -u shell [Shell Name | all] | utility [Utility Name | all]'"
echo
# increment session login count
ticker=$(( ${ticker} + 1 ))
echo ${ticker} > "${HOME}"/.dextop/dextop-ticker
sleep 1
# automatic session start
if [[ $(cat "${HOME}"/.dextop/dextop-login) = "login" ]]
then
frobulator.wrn "Automatic session start enabled"
echo
session_level="termux"
if [[ $(pgrep -f proot) ]]
then
session_level="container"
fi
# load session interface
session_level="${session_level^}"
frobulator.cpt "Loading ${session_level} level session" "[ ${session_interface} ]"
echo
container-session -o
fi
fi