fix: error log
This commit is contained in:
parent
757efc3ec6
commit
0b7d51be05
2 changed files with 65 additions and 38 deletions
49
.zprofile
49
.zprofile
|
@ -1,31 +1,38 @@
|
||||||
# ─< proxy config >───────────────────────────────────────────────────────────────────────
|
# ─< proxy config >───────────────────────────────────────────────────────────────────────
|
||||||
proxy() {
|
proxy() {
|
||||||
case "$1" in
|
|
||||||
--show)
|
|
||||||
echo {"http: $http_proxy, $HTTP_PROXY"
|
|
||||||
"https: $https_proxy, $HTTPS_PROXY"}
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "You entered something wrong!"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
local ip="172.22.11.69"
|
local ip="172.22.11.69"
|
||||||
local port="8080"
|
local port="8080"
|
||||||
|
|
||||||
# Check if the IP and port are reachable
|
if [ -z "$1" ]; then
|
||||||
if nc -z -w5 $ip $port; then
|
echo "Usage: proxy [--show|--set]"
|
||||||
# If reachable, set the proxy environment variables
|
echo " --show Show current proxy settings"
|
||||||
export http_proxy="http://$ip:$port"
|
echo " --set Set proxy to $ip:$port"
|
||||||
export https_proxy="http://$ip:$port"
|
return 0
|
||||||
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
|
fi
|
||||||
|
|
||||||
alias proxy='echo "http: $HTTP_PROXY"; echo "https: $HTTPS_PROXY"'
|
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 >────────────────────────────────────────────────────────────────────────
|
# ─< unset proxy >────────────────────────────────────────────────────────────────────────
|
||||||
|
|
54
.zshrc
54
.zshrc
|
@ -26,6 +26,26 @@ _MESSAGES=(
|
||||||
[info]=""
|
[info]=""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Define color variables
|
||||||
|
RED='\033[0;31m'
|
||||||
|
YELLOW='\033[0;33m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
BOLD='\033[1m'
|
||||||
|
|
||||||
|
# Functions to store messages
|
||||||
|
echo_error() {
|
||||||
|
_MESSAGES[error]+="${RED}❌ $1${NC}\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_warning() {
|
||||||
|
_MESSAGES[warn]+="${YELLOW}⚠️ $1${NC}\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_info() {
|
||||||
|
_MESSAGES[info]+="${CYAN}ℹ️ $1${NC}\n"
|
||||||
|
}
|
||||||
|
|
||||||
# Display stored messages
|
# Display stored messages
|
||||||
error_log() {
|
error_log() {
|
||||||
[[ -z "${_MESSAGES[error]}${_MESSAGES[warn]}${_MESSAGES[info]}" ]] && return 0
|
[[ -z "${_MESSAGES[error]}${_MESSAGES[warn]}${_MESSAGES[info]}" ]] && return 0
|
||||||
|
@ -128,7 +148,7 @@ __get_Packager__() {
|
||||||
alias remove="$_sudo apk del"
|
alias remove="$_sudo apk del"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported distro: $ID"
|
echo_error "Unsupported distro: $ID"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -418,23 +438,23 @@ _coding_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__sources__() {
|
__sources__() {
|
||||||
if [ -e "$HOME/.zshenv" ]; then
|
# if [ -e "$HOME/.zshenv" ]; then
|
||||||
echo_info "Loadet zshenv"
|
# echo_info "Loadet zshenv"
|
||||||
. "$HOME/.zshenv"
|
# . "$HOME/.zshenv"
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
if [ -e "$HOME/.bash_aliases" ]; then
|
# if [ -e "$HOME/.bash_aliases" ]; then
|
||||||
echo_info "Loadet bash_aliases"
|
# echo_info "Loadet bash_aliases"
|
||||||
. "$HOME/.bash_aliases"
|
# . "$HOME/.bash_aliases"
|
||||||
else
|
# else
|
||||||
if command_exists curl; then
|
# if command_exists curl; then
|
||||||
curl -fsSL https://git.k4li.de/dotfiles/bash/raw/branch/main/.bash_aliases -o "$HOME/.bash_aliases"
|
# curl -fsSL https://git.k4li.de/dotfiles/bash/raw/branch/main/.bash_aliases -o "$HOME/.bash_aliases"
|
||||||
echo_info "(Down)loadet bash_aliases"
|
# echo_info "(Down)loadet bash_aliases"
|
||||||
. "$HOME/.bash_aliases"
|
# . "$HOME/.bash_aliases"
|
||||||
else
|
# else
|
||||||
echo_warning "Couldn't setup aliases properly.."
|
# echo_warning "Couldn't setup aliases properly.."
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
local sourceDir="$HOME/.zsh"
|
local sourceDir="$HOME/.zsh"
|
||||||
local sourceOptions=(
|
local sourceOptions=(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue