Addet proxy config again and changed ble-import to just use my own source func
This commit is contained in:
parent
88d5d3f6bc
commit
c43c508b1e
2 changed files with 63 additions and 5 deletions
8
.bashrc
8
.bashrc
|
@ -127,7 +127,6 @@ source-file() {
|
|||
source $file
|
||||
else
|
||||
file=$1
|
||||
|
||||
[[ -e "$file" ]] &&
|
||||
source $file &&
|
||||
echo "Sourced $file"
|
||||
|
@ -251,7 +250,7 @@ _init() {
|
|||
if command-exists fzf; then
|
||||
|
||||
if $blesh; then
|
||||
return
|
||||
echo
|
||||
else
|
||||
eval "$(fzf --bash)" || {
|
||||
source-file "$HOME/.fzf/shell/completion.bash"
|
||||
|
@ -419,10 +418,9 @@ main() {
|
|||
setup-pkg
|
||||
show-end-screen
|
||||
|
||||
ble-import "$HOME/.bash_aliases"
|
||||
source-file -q "$HOME/.bash_aliases"
|
||||
source-file -q "$HOME/.bash/plugins/autopairs.sh"
|
||||
# ble-import "$HOME/.bash/plugins/autopairs.sh"
|
||||
# source-file -q "$HOME/.bash_aliases"
|
||||
source-file -q "$HOME/.proxy"
|
||||
|
||||
if command-exists keychain; then
|
||||
eval "$(keychain --eval --noask --agents ssh ~/.ssh/{homelab-id_rsa,hetzner_id_rsa})"
|
||||
|
|
60
.proxy
Normal file
60
.proxy
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue