zsh/.zshdef
2025-03-12 08:58:13 +01:00

86 lines
2.7 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ─< Helper functions >─────────────────────────────────────────────────────────────────
# ANSI color codes
RED='\033[0;31m'
CYAN='\033[0;36m'
YELLOW='\033[0;33m'
LIGHT_GREEN='\033[0;92m'
BOLD='\033[1m'
NC='\033[0m' # No Color
# Logging functions with emojis
echo_error() {
local msg="${RED}❌ $1${NC}\n"
# printf "$msg" >&2
_MESSAGES[error]+="$msg"
}
echo_warning() {
local msg="${YELLOW}⚠️ $1${NC}\n"
# printf "$msg"
_MESSAGES[warn]+="$msg"
}
echo_info() {
local msg="${CYAN} $1${NC}\n"
# printf "$msg"
_MESSAGES[info]+="$msg"
}
# ─< proxy config >───────────────────────────────────────────────────────────────────────
proxy() {
local ip="172.22.11.69"
local port="8080"
# 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"
else
echo_error "IP $ip with port $port is not reachable."
fi
alias proxy='echo "http: $HTTP_PROXY"; echo "https: $HTTPS_PROXY"'
}
# ─< unset proxy >────────────────────────────────────────────────────────────────────────
noproxy() {
unset {HTTP_PROXY,HTTPS_PROXY,http_proxy,https_proxy}
}
# Load completions
autoload -Uz compinit && compinit
bindkey -e
# # Define custom word style that treats special characters as word boundaries
autoload -Uz select-word-style
select-word-style bash
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups
# Huge history. Doesn't appear to slow things down, so why not?
HISTSIZE=500000
HISTFILESIZE=100000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
# Completion styling
zstyle :compinstall filename "$HOME/.zshrc"
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
# zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
setopt autocd notify
# End of lines configured by zsh-newuser-install