fixes.. and removed old .zprofile
This commit is contained in:
parent
b69b3efd2e
commit
4647949a2a
2 changed files with 61 additions and 55 deletions
47
.zprofile
47
.zprofile
|
@ -1,47 +0,0 @@
|
||||||
# ─< proxy config >───────────────────────────────────────────────────────────────────────
|
|
||||||
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:"
|
|
||||||
echo "http: $http_proxy, HTTP: $HTTP_PROXY"
|
|
||||||
echo "https: $https_proxy, HTTPS: $HTTPS_PROXY"
|
|
||||||
;;
|
|
||||||
--set)
|
|
||||||
# Check if the IP and port are reachable
|
|
||||||
if nc -z -w5 $ip $port; then
|
|
||||||
# If reachable, set the proxy environment variables
|
|
||||||
export http_proxy="http://$ip:$port"
|
|
||||||
export https_proxy="http://$ip:$port"
|
|
||||||
export HTTP_PROXY="http://$ip:$port"
|
|
||||||
export HTTPS_PROXY="http://$ip:$port"
|
|
||||||
echo_info "Proxy set to: http://$ip:$port" || echo "Proxy set to: http://$ip:$port"
|
|
||||||
else
|
|
||||||
echo_error "IP $ip with port $port is not reachable." || echo "IP $ip with port $port is not reachable."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Invalid option! Use --show or --set."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─< unset proxy >────────────────────────────────────────────────────────────────────────
|
|
||||||
noproxy() {
|
|
||||||
unset {HTTP_PROXY,HTTPS_PROXY,http_proxy,https_proxy}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ping -w2 -q swu.dom; then
|
|
||||||
proxy
|
|
||||||
else
|
|
||||||
noproxy
|
|
||||||
fi
|
|
69
.zshenv
69
.zshenv
|
@ -30,7 +30,9 @@ command_exists() {
|
||||||
command -v "$@" >/dev/null 2>&1
|
command -v "$@" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─< paths >──────────────────────────────────────────────────────────────────────────────
|
# ╭───────╮
|
||||||
|
# │ paths │
|
||||||
|
# ╰───────╯
|
||||||
if [ -d "$HOME/.local/bin" ]; then
|
if [ -d "$HOME/.local/bin" ]; then
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
if [ -e "$HOME/.local/bin/lazydocker" ]; then
|
if [ -e "$HOME/.local/bin/lazydocker" ]; then
|
||||||
|
@ -49,13 +51,13 @@ else
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ─< go bin path >────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────< go bin path >───────────────────────────────────
|
||||||
[ -d "$HOME/go/bin" ] && {
|
[ -d "$HOME/go/bin" ] && {
|
||||||
export PATH="$HOME/go/bin:$PATH"
|
export PATH="$HOME/go/bin:$PATH"
|
||||||
echo_info "Go programs at $HOME/go/bin/"
|
echo_info "Go programs at $HOME/go/bin/"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─< cargo bin path >─────────────────────────────────────────────────────────────────────
|
# ────────────────────────────────────< cargo bin path >────────────────────────────────────
|
||||||
if [ -e "$HOME/.cargo/env" ]; then
|
if [ -e "$HOME/.cargo/env" ]; then
|
||||||
echo_info "Loadet $HOME/.cargo/env"
|
echo_info "Loadet $HOME/.cargo/env"
|
||||||
. "$HOME/.cargo/env"
|
. "$HOME/.cargo/env"
|
||||||
|
@ -66,9 +68,60 @@ else
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# bun completions
|
# ──────────────────────────────────────< fzf plugin >──────────────────────────────────────
|
||||||
# [ -s "$HOME/.bun/_bun" ] && . "$HOME/.bun/_bun"
|
[ -d "$HOME/.zsh/plugins/fzf-zsh-plugin/bin" ] &&
|
||||||
# [ -s "$HOME/.bun/_bun" ] && export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
|
export PATH="$HOME/.zsh/plugins/fzf-zsh-plugin/bin:$PATH"
|
||||||
|
|
||||||
# ─< fzf plugin >─────────────────────────────────────────────────────────────────────────
|
# ╭──────────────╮
|
||||||
[ -d "$HOME/.zsh/plugins/fzf-zsh-plugin/bin" ] && export PATH="$HOME/.zsh/plugins/fzf-zsh-plugin/bin:$PATH"
|
# │ 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:"
|
||||||
|
echo "http: ${http_proxy}, HTTP: ${HTTP_PROXY}"
|
||||||
|
echo "https: ${https_proxy}, HTTPS: ${HTTPS_PROXY}"
|
||||||
|
;;
|
||||||
|
--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}"
|
||||||
|
export http_proxy="${proxy}"
|
||||||
|
export https_proxy="${proxy}"
|
||||||
|
export HTTP_PROXY="${proxy}"
|
||||||
|
export HTTPS_PROXY="${proxy}"
|
||||||
|
echo "Proxy set to: http://$ip:$port"
|
||||||
|
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 -w2 -q swu.dom; then
|
||||||
|
proxy --set
|
||||||
|
else
|
||||||
|
noproxy
|
||||||
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue