-
Notifications
You must be signed in to change notification settings - Fork 37
/
advanced_development_shell_tools.rc
180 lines (150 loc) · 6.06 KB
/
advanced_development_shell_tools.rc
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
#!/bin/bash
#
# Copyright 2015-2020 Adrian DC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# === Shell Entrypoint Handling ===
ADVANCED_DEVELOPMENT_SHELL_TOOLS_ENTRYPOINT=${BASH_SOURCE[0]};
ADVANCED_DEVELOPMENT_SHELL_TOOLS_ENTRYPOINT=${ADVANCED_DEVELOPMENT_SHELL_TOOLS_ENTRYPOINT:-${(%):-%N}};
ADVANCED_DEVELOPMENT_SHELL_TOOLS_ENTRYPOINT=$(readlink -f "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_ENTRYPOINT}");
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_ENTRYPOINT;
if [ -z "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_ENTRYPOINT}" ]; then
echo '';
echo -e ' \e[1;33madvanced_development_shell_tools by AdrianDC: \e[1;31mExecution path could not be found\e[0m';
echo '';
return;
fi;
# === Advanced Development Shell Tools Folders ===
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_DIR=${ADVANCED_DEVELOPMENT_SHELL_TOOLS_ENTRYPOINT%/*};
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_EXTENSIONS_DIR=${ADVANCED_DEVELOPMENT_SHELL_TOOLS_DIR}/extensions;
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_PROJECT_DIR=${ADVANCED_DEVELOPMENT_SHELL_TOOLS_DIR}/project;
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_SCRIPTS_DIR=${ADVANCED_DEVELOPMENT_SHELL_TOOLS_DIR}/scripts;
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_SOURCES_DIR=${ADVANCED_DEVELOPMENT_SHELL_TOOLS_DIR}/sources;
# === Advanced Development Shell Tools Variables ===
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_BRANCH='master';
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_VERSION='2020.1';
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_URL='https://github.com/AdrianDC/advanced_development_shell_tools';
# === Advanced Development Shell Tools Workspace ===
if [ -z "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_WORKSPACE:-${HOME}}" ]; then
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_WORKSPACE=~;
fi;
# === Advanced Development Shell Tools Configuration ===
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_CONFIGURATION=${ADVANCED_DEVELOPMENT_SHELL_TOOLS_WORKSPACE:-${HOME}}/.bash_advanced_development_shell_tools.rc;
# === Advanced Development Shell Tools Configuration Migration ===
ANDROID_DEVELOPMENT_SHELL_TOOLS_CONFIGURATION=${ADVANCED_DEVELOPMENT_SHELL_TOOLS_WORKSPACE:-${HOME}}/.bash_android_development_shell_tools.rc;
if [ -f "${ANDROID_DEVELOPMENT_SHELL_TOOLS_CONFIGURATION}" ] && [ ! -f "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_CONFIGURATION}" ]; then
mv "${ANDROID_DEVELOPMENT_SHELL_TOOLS_CONFIGURATION}" "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_CONFIGURATION}";
sed -i 's/Android Development Shell Tools/Advanced Development Shell Tools/g' "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_CONFIGURATION}";
fi;
# === Advanced Development Shell Tools Sources ===
function shtoolssources()
{
# Usage: shtoolssources (List sources from advanced_development_shell_tools)
# Variables
local file_path;
local LC_ALL_HOST;
# Locale override
LC_ALL_HOST=${LC_ALL};
export LC_ALL=C;
# Advanced Development Shell Tools Project
for file_path in "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_PROJECT_DIR}/"*'.rc'; do
if [ -f "${file_path}" ]; then
echo "${file_path}";
fi;
done;
# Advanced Development Shell Tools Sources
for file_path in "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_SOURCES_DIR}/"*'/'*'.rc'; do
if [ -f "${file_path}" ]; then
echo "${file_path}";
fi;
done;
# Advanced Development Shell Tools Extensions
for file_path in "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_EXTENSIONS_DIR}/"*'/'*'.rc'; do
if [ -f "${file_path}" ]; then
echo "${file_path}";
fi;
done;
# Advanced Development Shell Tools Cleanup
export LC_ALL=${LC_ALL_HOST};
}
# === Advanced Development Shell Tools Scripts ===
function shtoolsscripts()
{
# Usage: shtoolsscripts (List scripts from advanced_development_shell_tools)
# Variables
local file_path;
local LC_ALL_HOST;
# Locale override
LC_ALL_HOST=${LC_ALL};
export LC_ALL=C;
# Advanced Development Shell Tools Scripts
for file_path in "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_SCRIPTS_DIR}/"*'/'*'.sh'; do
if [ -f "${file_path}" ]; then
echo "${file_path}";
fi;
done;
# Advanced Development Shell Tools Cleanup
export LC_ALL=${LC_ALL_HOST};
}
# === Advanced Development Shell Tools Instance ===
function shtoolsinstance()
{
# Usage: shtoolsinstance (Instantiate advanced_development_shell_tools)
# Variables
local file_path;
local group;
local tmp_list;
# Header
echo -en ' \e[1;33madvanced_development_shell_tools: \e[1;37mLoading project...\e[0m';
# Import sources
tmp_list=$(mktemp);
shtoolssources > "${tmp_list}";
while read -r file_path; do
group=${file_path#${ADVANCED_DEVELOPMENT_SHELL_TOOLS_DIR}/};
group=${group%/*};
source "${file_path}";
done < "${tmp_list}"
rm -f "${tmp_list}";
# Cleanup
echo -en "\r\033[K";
# Import addons definitions
source "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_DIR}/addons/definitions.rc";
# First launch detection
if [ ! -f "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_CONFIGURATION}" ]; then
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_FIRST_LAUNCH='true';
__shtools-config-news-enable;
# Regular launch
else
export ADVANCED_DEVELOPMENT_SHELL_TOOLS_FIRST_LAUNCH='';
fi;
# Verify git is installed
if ! type git >/dev/null 2>&1; then
echo '';
echo -en '\r\033[K \e[1;33madvanced_development_shell_tools: \e[1;31mPlease install git...\e[0m';
echo '';
echo '';
return;
fi;
# Submodules instantiation
if [ ! -z "${ADVANCED_DEVELOPMENT_SHELL_TOOLS_FIRST_LAUNCH}" ]; then
git submodule update --init;
git submodule update --init --remote 2>/dev/null;
fi;
# Automated project news
if __shtools-config-news-active; then
ADVANCED_DEVELOPMENT_SHELL_TOOLS_INSTANTIATION=true shtoolsnews;
fi;
}
# === Advanced Development Shell Tools Instantiation ===
shtoolsinstance;