Skip to content

Commit d604d30

Browse files
authored
saner
1 parent 0d369b0 commit d604d30

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

Linux/.bashrc

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ export LANGUAGE="${LANGUAGE:-en_US:en}"
108108
export LANG="${LANG:-en_US.UTF-8}"
109109
export LC_ALL="${LC_ALL:-${LANG}}" 2>/dev/null
110110
export TMOUT="0"
111-
BW_INTERFACE="$(ip route | grep -i 'default' | awk '{print $5}' | tr -d '[:space:]')" && export BW_INTERFACE="${BW_INTERFACE}"
111+
BW_INTERFACE="$(ip route show '0/0' | grep -i 'default' | grep -oP 'dev\s+\K\S+' | head -n 1 | tr -d '"'\''[:space:]')"
112+
export BW_INTERFACE
112113
current_dir="$(pwd)"
113114
##PATHS (Only Required)
114115
if [[ -z "${GOROOT}" && -d "${HOME}/.go" ]]; then
@@ -210,6 +211,15 @@ function install_soar()
210211
soar sync
211212
}
212213
export -f install_soar
214+
function decode_base64()
215+
{
216+
if [[ -f "$1" ]]; then
217+
base64 -d "$1"
218+
else
219+
echo "${1:-$(cat)}" | base64 -d
220+
fi
221+
}
222+
export -f decode_base64
213223
function disable_fzf()
214224
{
215225
unset "$(set | grep -o '^_fzf[^=]*' | tr '\n' ' ')" 2>/dev/null
@@ -225,6 +235,28 @@ function disable_fzf()
225235
fi
226236
}
227237
export -f disable_fzf
238+
function encode_base64()
239+
{
240+
if [[ -f "$1" ]]; then
241+
base64 -w0 "$1"
242+
else
243+
echo "${1:-$(cat)}" | base64 -w0
244+
fi
245+
}
246+
export -f encode_base64
247+
function fix_validate_jsonl()
248+
{
249+
if ! awk --version 2>&1 | grep -qi "busybox"; then
250+
if [[ -f "$1" ]]; then
251+
awk '/^\s*{\s*$/ {flag=1;buffer="{\n";next} /^\s*}\s*$/ {if(flag){print buffer"}\n"};flag=0;next} flag{buffer=buffer$0"\n"} /^\{.*\}$/ {print $0"\n"}' "$1"
252+
else
253+
echo "${1:-$(cat)}" | awk '/^\s*{\s*$/ {flag=1;buffer="{\n";next} /^\s*}\s*$/ {if(flag){print buffer"}\n"};flag=0;next} flag{buffer=buffer$0"\n"} /^\{.*\}$/ {print $0"\n"}'
254+
fi
255+
else
256+
echo "BusyBox awk Detected, Install GnuAWK(gawk)"
257+
fi
258+
}
259+
export -f fix_validate_jsonl
228260
function install_soar_force()
229261
{
230262
if [[ ! -d "${HOME}/bin" ]]; then
@@ -269,6 +301,34 @@ function strip_debug()
269301
strip --strip-debug --strip-dwo --strip-unneeded "$1" 2>/dev/null
270302
}
271303
export -f strip_debug
304+
function strip_space_stdin()
305+
{
306+
if [[ -f "$1" ]]; then
307+
sed 's/^[[:space:]]*//;s/[[:space:]]*$//' "$1"
308+
else
309+
echo "${1:-$(cat)}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'
310+
fi
311+
}
312+
export -f strip_space_stdin
313+
function strip_space_tr()
314+
{
315+
echo "${1:-$(cat)}" | tr -d '"'\''[:space:]'
316+
}
317+
export -f strip_space_tr
318+
function url_decode_py()
319+
{
320+
if command -v python &>/dev/null; then
321+
echo "${1:-$(cat)}" | python -c 'import sys, urllib.parse; print(urllib.parse.unquote(sys.stdin.read().strip()))'
322+
elif
323+
echo "${1:-$(cat)}" | python3 -c 'import sys, urllib.parse; print(urllib.parse.unquote(sys.stdin.read().strip()))'
324+
fi
325+
}
326+
export -f url_decode_py
327+
function url_encode_jq()
328+
{
329+
echo "${1:-$(cat)}" | jq -sRr '@uri' | tr -d '[:space:]'
330+
}
331+
export -f url_encode_jq
272332
#-------------------------------------------------------------------------------#
273333

274334
#-------------------------------------------------------------------------------#

0 commit comments

Comments
 (0)