Addet proxy config again and changed ble-import to just use my own source func

This commit is contained in:
piecka 2025-07-09 10:11:11 +02:00
parent 88d5d3f6bc
commit c43c508b1e
2 changed files with 63 additions and 5 deletions

View file

@ -127,7 +127,6 @@ source-file() {
source $file source $file
else else
file=$1 file=$1
[[ -e "$file" ]] && [[ -e "$file" ]] &&
source $file && source $file &&
echo "Sourced $file" echo "Sourced $file"
@ -251,7 +250,7 @@ _init() {
if command-exists fzf; then if command-exists fzf; then
if $blesh; then if $blesh; then
return echo
else else
eval "$(fzf --bash)" || { eval "$(fzf --bash)" || {
source-file "$HOME/.fzf/shell/completion.bash" source-file "$HOME/.fzf/shell/completion.bash"
@ -419,10 +418,9 @@ main() {
setup-pkg setup-pkg
show-end-screen show-end-screen
ble-import "$HOME/.bash_aliases" source-file -q "$HOME/.bash_aliases"
source-file -q "$HOME/.bash/plugins/autopairs.sh" source-file -q "$HOME/.bash/plugins/autopairs.sh"
# ble-import "$HOME/.bash/plugins/autopairs.sh" source-file -q "$HOME/.proxy"
# source-file -q "$HOME/.bash_aliases"
if command-exists keychain; then if command-exists keychain; then
eval "$(keychain --eval --noask --agents ssh ~/.ssh/{homelab-id_rsa,hetzner_id_rsa})" eval "$(keychain --eval --noask --agents ssh ~/.ssh/{homelab-id_rsa,hetzner_id_rsa})"

60
.proxy Normal file
View file

@ -0,0 +1,60 @@
#!/usr/bin/env bash
# ╭──────────────╮
# │ proxy config │
# ╰──────────────╯
# ─────────────────────────────────────< unset proxy >───────────────────────────────────
noproxy() {
unset {HTTP_PROXY,HTTPS_PROXY,http_proxy,https_proxy}
}
# ──────────────────< proxy function to set or show the proxy variables >────────────────
proxy() {
local ip="172.22.11.69"
local port="8080"
if [ -z "$1" ]; then
echo "Usage: proxy [--show|--set]"
echo " --show Show current proxy settings"
echo " --set Set proxy to $ip:$port"
return 0
fi
case "$1" in
--show)
echo "These are your proxy configurations:"
if [ -n "${http_proxy}" ] || [ -n "${HTTP_PROXY}" ] || [ -n "${https_proxy}" ] || [ -n "${HTTPS_PROXY}" ]; then
echo "http: ${http_proxy}| HTTP: ${HTTP_PROXY}"
echo "https: ${https_proxy}| HTTPS: ${HTTPS_PROXY}"
else
echo "No proxy configured."
fi
;;
--set)
# ─< Check if the IP and port are reachable >─────────────────────────────────────────────
if nc -z -w5 $ip $port; then
# ─< If reachable, set the proxy environment variables >──────────────────────────────────
local proxy="http://${ip}:${port}"
for e in http_proxy HTTP_PROXY https_proxy HTTPS_PROXY; do
export "${e}=${proxy}"
done
echo "Proxy set to: $proxy"
else
echo "IP $ip with port $port is not reachable."
fi
;;
*)
echo "Invalid option! Use --show or --set."
;;
esac
}
# ────────────< check network availability and set proxy if in correct network >────────────
noproxy
if ping -c 1 -W 2 swu.dom &>/dev/null; then
proxy --set
else
noproxy
fi