some changes
This commit is contained in:
parent
cea0b562e9
commit
47a2952674
3 changed files with 149 additions and 94 deletions
86
.zshdef
Normal file
86
.zshdef
Normal file
|
@ -0,0 +1,86 @@
|
|||
# ─< 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
|
37
.zshenv
Normal file
37
.zshenv
Normal file
|
@ -0,0 +1,37 @@
|
|||
# ─< paths >──────────────────────────────────────────────────────────────────────────────
|
||||
if [ -d "$HOME/.local/bin" ]; then
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
if [ -e "$HOME/.local/bin/lazydocker" ]; then
|
||||
alias ld="$HOME/.local/bin/lazydocker"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ─< linux binary via script installation >───────────────────────────────────────────────
|
||||
[ -d "$HOME/.bin/nvim-linux64/bin" ] && {
|
||||
export PATH="$HOME/.bin/nvim-linux64/bin:$PATH"
|
||||
echo_info "neovim at $HOME/.bin/nvim-linux64/bin/nvim"
|
||||
}
|
||||
|
||||
# ─< go bin path >────────────────────────────────────────────────────────────────────────
|
||||
[ -d "$HOME/go/bin" ] && {
|
||||
export PATH="$HOME/go/bin:$PATH"
|
||||
echo_info "Go programs at $HOME/go/bin/"
|
||||
}
|
||||
|
||||
# ─< cargo bin path >─────────────────────────────────────────────────────────────────────
|
||||
if [ -e "$HOME/.cargo/env" ]; then
|
||||
echo_info "Loadet $HOME/.cargo/env"
|
||||
. "$HOME/.cargo/env"
|
||||
else
|
||||
[ -d "$HOME/.cargo/bin" ] && {
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
echo_info "Cargo programs at $HOME/.cargo/bin/"
|
||||
}
|
||||
fi
|
||||
|
||||
# bun completions
|
||||
# [ -s "$HOME/.bun/_bun" ] && . "$HOME/.bun/_bun"
|
||||
# [ -s "$HOME/.bun/_bun" ] && export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
|
||||
|
||||
# ─< fzf plugin >─────────────────────────────────────────────────────────────────────────
|
||||
[ -d "$HOME/.zsh/plugins/fzf-zsh-plugin/bin" ] && export PATH="$HOME/.zsh/plugins/fzf-zsh-plugin/bin:$PATH"
|
120
.zshrc
120
.zshrc
|
@ -1,36 +1,26 @@
|
|||
# ─< 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
|
||||
[[ -e "$HOME/.zshdef" ]] && . "$HOME/.zshdef" # <-- Defaults like echos and colors
|
||||
|
||||
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"
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
#
|
||||
# Check if the user is root and set sudo variable if necessary
|
||||
check_root() {
|
||||
if [[ "${EUID}" -ne 0 ]]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User <$(whoami)> is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
fi
|
||||
else
|
||||
echo_error "IP $ip with port $port is not reachable."
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
|
||||
alias proxy='echo "http: $HTTP_PROXY"; echo "https: $HTTPS_PROXY"'
|
||||
}
|
||||
|
||||
noproxy() {
|
||||
unset {HTTP_PROXY,HTTPS_PROXY,http_proxy,https_proxy}
|
||||
}
|
||||
|
||||
# Message storage
|
||||
# ───────────────────────────────────< Message storage >─────────────────────────────────
|
||||
typeset -A _MESSAGES
|
||||
_MESSAGES=(
|
||||
[error]=""
|
||||
|
@ -38,25 +28,6 @@ _MESSAGES=(
|
|||
[info]=""
|
||||
)
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
||||
# Display stored messages
|
||||
error_log() {
|
||||
[[ -z "${_MESSAGES[error]}${_MESSAGES[warn]}${_MESSAGES[info]}" ]] && return 0
|
||||
|
@ -81,26 +52,6 @@ error_log() {
|
|||
done
|
||||
}
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Check if the user is root and set sudo variable if necessary
|
||||
check_root() {
|
||||
if [[ "${EUID}" -ne 0 ]]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User <$(whoami)> is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
_init() {
|
||||
if command_exists oh-my-posh; then
|
||||
# eval "$(oh-my-posh init zsh --config 'https://git.k4li.de/dotfiles/oh-my-posh/raw/branch/main/amro.toml')"
|
||||
|
@ -123,11 +74,18 @@ _init() {
|
|||
}
|
||||
|
||||
_sources() {
|
||||
if [ -e "$HOME/.zshenv" ]; then
|
||||
echo_info "Loadet zshenv"
|
||||
. "$HOME/.zshenv"
|
||||
fi
|
||||
|
||||
if [ -e "$HOME/.bash_aliases" ]; then
|
||||
echo_info "Loadet bash_aliases"
|
||||
. "$HOME/.bash_aliases"
|
||||
else
|
||||
if command_exists curl; then
|
||||
curl -fsSL https://git.k4li.de/dotfiles/bash/raw/branch/main/.bash_aliases -o "$HOME/.bash_aliases"
|
||||
echo_info "(Down)loadet bash_aliases"
|
||||
. "$HOME/.bash_aliases"
|
||||
else
|
||||
echo_warning "Couldn't setup aliases properly.."
|
||||
|
@ -136,7 +94,6 @@ _sources() {
|
|||
|
||||
local sourceDir="$HOME/.zsh"
|
||||
local sourceOptions=(
|
||||
# "$_alias"
|
||||
"defaults"
|
||||
"plugins"
|
||||
"installs"
|
||||
|
@ -151,31 +108,6 @@ _sources() {
|
|||
done
|
||||
}
|
||||
|
||||
_environment() {
|
||||
if command_exists nvim; then
|
||||
export EDITOR="$(which nvim)"
|
||||
fi
|
||||
|
||||
# ─< paths >──────────────────────────────────────────────────────────────────────────────
|
||||
if [ -d "$HOME/.local/bin" ]; then
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
if [ -e "$HOME/.local/bin/lazydocker" ]; then
|
||||
alias ld="$HOME/.local/bin/lazydocker"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -d "$HOME/go/bin" ] && export PATH="$HOME/go/bin:$PATH"
|
||||
[ -d "$HOME/.cargo/bin" ] && export PATH="$HOME/.cargo/bin:$PATH"
|
||||
|
||||
[ -e "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
|
||||
|
||||
# bun completions
|
||||
[ -s "$HOME/.bun/_bun" ] && . "$HOME/.bun/_bun"
|
||||
[ -s "$HOME/.bun/_bun" ] && export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
|
||||
|
||||
[ -d "$HOME/.zsh/plugins/fzf-zsh-plugin/bin" ] && export PATH="$HOME/.zsh/plugins/fzf-zsh-plugin/bin:$PATH"
|
||||
}
|
||||
|
||||
_end() {
|
||||
if command_exists fastfetch; then
|
||||
clear &&
|
||||
|
@ -191,7 +123,7 @@ _end() {
|
|||
}
|
||||
|
||||
main() {
|
||||
_environment
|
||||
proxy
|
||||
_init
|
||||
_sources
|
||||
_end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue