Skip to content

Commit 703d0f0

Browse files
authored
saner
1 parent 9842fd2 commit 703d0f0

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

Linux/.bashrc

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ if sudo -n true 2>/dev/null; then
2626
else
2727
export PASSWORDLESS_SUDO="0"
2828
fi
29+
##Has curl
30+
if ! command -v curl &>/dev/null; then
31+
export HAS_CURL="0"
32+
echo "[-] WARNING: curl is not Installed (A lot of things will Break)"
33+
else
34+
export HAS_CURL="1"
35+
fi
2936
##Apperance
3037
if [[ "$(tput colors 2>/dev/null | tr -d '[:space:]')" -eq 256 ]]; then
3138
export TERM="xterm-256color"
@@ -102,7 +109,7 @@ if [[ -z "${HOST_TRIPLET}" ]] || [[ -z "${HOST_TRIPLET##*[[:space:]]}" ]]; then
102109
export HOST_TRIPLET
103110
fi
104111
if [[ -z "${USER_AGENT}" ]]; then
105-
USER_AGENT="$(curl -qfsSL 'https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Misc/User-Agents/ua_chrome_macos_latest.txt')"
112+
[[ "${HAS_CURL}" == 1 ]] && USER_AGENT="$(curl -qfsSL 'https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Misc/User-Agents/ua_chrome_macos_latest.txt')"
106113
fi
107114
if [[ -z "${SYSTMP+x}" ]] || [[ -z "${SYSTMP##*[[:space:]]}" ]]; then
108115
SYSTMP="$(dirname "$(mktemp -u)" | tr -d '[:space:]')"
@@ -209,7 +216,7 @@ function install_soar()
209216
if [[ ! -d "${HOME}/bin" ]]; then
210217
mkdir -p "${HOME}/bin"
211218
fi
212-
bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/soar/refs/heads/main/install.sh")
219+
[[ "${HAS_CURL}" == 1 ]] && bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/soar/refs/heads/main/install.sh")
213220
command -v soar &>/dev/null || return 1
214221
if [[ ! -s "${HOME}/.config/soar/config.toml" ]]; then
215222
soar defconfig --external
@@ -285,7 +292,7 @@ function install_soar_force()
285292
mkdir -p "${HOME}/.local/bin"
286293
fi
287294
rm -rvf "${HOME}/.config/soar" "${HOME}/.local/share/soar" 2>/dev/null
288-
bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/soar/refs/heads/main/install.sh")
295+
[[ "${HAS_CURL}" == 1 ]] && bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/soar/refs/heads/main/install.sh")
289296
command -v soar &>/dev/null || return 1
290297
soar defconfig --external
291298
soar sync
@@ -314,15 +321,39 @@ function refreshenv()
314321
source "$(realpath "${HOME}/.bashrc" | tr -d '[:space:]')"
315322
}
316323
export -f refreshenv
324+
function refresh_bashrc()
325+
{
326+
BASHRC_SRC_URL="https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/.bashrc"
327+
if [[ "${PASSWORDLESS_SUDO}" == 1 ]]; then
328+
if [[ "${HAS_CURL}" == 1 ]]; then
329+
sudo curl -qfsSL "${BASHRC_SRC_URL}" -H "Cache-Control: no-cache" -H "Pragma: no-cache" -H "Expires: 0" -o "/etc/bash.bashrc" &&\
330+
curl -qfsSL "${BASHRC_SRC_URL}" -w "(SRC) <== %{url}\n" -I
331+
if [[ -f "/etc/bash.bashrc" ]]; then
332+
sudo ln -fs "/etc/bash.bashrc" "/root/.bashrc" 2>/dev/null
333+
sudo ln -fs "/etc/bash.bashrc" "${HOME}/.bashrc" 2>/dev/null
334+
sudo ln -fs "/etc/bash.bashrc" "/etc/bash/bashrc" 2>/dev/null
335+
fi
336+
fi
337+
elif [[ -w "${HOME}" ]]; then
338+
if [[ "${HAS_CURL}" == 1 ]]; then
339+
curl -qfsSL "${BASHRC_SRC_URL}" -H "Cache-Control: no-cache" -H "Pragma: no-cache" -H "Expires: 0" -o "${HOME}/.bashrc" &&\
340+
curl -qfsSL "${BASHRC_SRC_URL}" -w "(SRC) <== %{url}\n" -I
341+
fi
342+
fi
343+
refreshenv
344+
}
345+
export -f refresh_bashrc
317346
function setup_fzf()
318347
{
319348
if [[ -d "${HOME}/.local/bin" ]] && [[ -w "${HOME}/.local/bin" ]]; then
320-
curl -w "(DL) <== %{url}\n" -qfsSL "https://bin.pkgforge.dev/${HOST_TRIPLET}/bat" -o "${HOME}/.local/bin/bat"
321-
curl -w "(DL) <== %{url}\n" -qfsSL "https://bin.pkgforge.dev/${HOST_TRIPLET}/fd" -o "${HOME}/.local/bin/fd"
322-
curl -w "(DL) <== %{url}\n" -qfsSL "https://bin.pkgforge.dev/${HOST_TRIPLET}/fzf" -o "${HOME}/.local/bin/fzf"
323-
curl -w "(DL) <== %{url}\n" -qfsSL "https://bin.pkgforge.dev/${HOST_TRIPLET}/tree" -o "${HOME}/.local/bin/tree"
324-
chmod 'a+x' "${HOME}/.local/bin/bat" "${HOME}/.local/bin/fd" "${HOME}/.local/bin/fzf" "${HOME}/.local/bin/tree"
325-
init_fzf && fzf --version && fzf
349+
if [[ "${HAS_CURL}" == 1 ]]; then
350+
curl -w "(DL) <== %{url}\n" -qfsSL "https://bin.pkgforge.dev/${HOST_TRIPLET}/bat" -o "${HOME}/.local/bin/bat"
351+
curl -w "(DL) <== %{url}\n" -qfsSL "https://bin.pkgforge.dev/${HOST_TRIPLET}/fd" -o "${HOME}/.local/bin/fd"
352+
curl -w "(DL) <== %{url}\n" -qfsSL "https://bin.pkgforge.dev/${HOST_TRIPLET}/fzf" -o "${HOME}/.local/bin/fzf"
353+
curl -w "(DL) <== %{url}\n" -qfsSL "https://bin.pkgforge.dev/${HOST_TRIPLET}/tree" -o "${HOME}/.local/bin/tree"
354+
chmod 'a+x' "${HOME}/.local/bin/bat" "${HOME}/.local/bin/fd" "${HOME}/.local/bin/fzf" "${HOME}/.local/bin/tree"
355+
init_fzf && fzf --version && fzf
356+
fi
326357
fi
327358
}
328359
export -f setup_fzf

0 commit comments

Comments
 (0)