some changes again..

This commit is contained in:
pika 2025-03-17 11:35:54 +01:00
parent 47a2952674
commit 71f8167a22
3 changed files with 418 additions and 49 deletions

48
.zshdef
View file

@ -28,6 +28,16 @@ echo_info() {
# ─< proxy config >───────────────────────────────────────────────────────────────────────
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 port="8080"
@ -38,9 +48,9 @@ proxy() {
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_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_error "IP $ip with port $port is not reachable." || echo "IP $ip with port $port is not reachable."
fi
alias proxy='echo "http: $HTTP_PROXY"; echo "https: $HTTPS_PROXY"'
@ -50,37 +60,3 @@ 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

15
.zshenv
View file

@ -6,11 +6,16 @@ if [ -d "$HOME/.local/bin" ]; then
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"
}
if command -v nvim 2 >/dev/null &>1; then
export EDITOR="nvim"
else
# ─< linux binary via script installation >───────────────────────────────────────────────
[ -d "$HOME/.bin/nvim-linux64/bin" ] && {
export PATH="$HOME/.bin/nvim-linux64/bin:$PATH"
export EDITOR="$HOME/.bin/nvim-linux64/bin/nvim"
echo_info "neovim at $HOME/.bin/nvim-linux64/bin/nvim"
}
fi
# ─< go bin path >────────────────────────────────────────────────────────────────────────
[ -d "$HOME/go/bin" ] && {

404
.zshrc
View file

@ -52,7 +52,7 @@ error_log() {
done
}
_init() {
__shell_qol__() {
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')"
# eval "$(oh-my-posh init zsh --config '~/.zsh/themes/sim-web.toml')"
@ -73,7 +73,353 @@ _init() {
fi
}
_sources() {
__get_Packager__() {
# Load OS release information
[ -f /etc/os-release ] && . /etc/os-release || return 1
DISTRO="${ID}:${ID_LIKE}"
case "$DISTRO" in
*debian*)
if command_exists nala; then
alias search="nala search"
alias install="$_sudo nala install --assume-yes"
alias update="$_sudo nala update && $_sudo nala upgrade --full"
alias remove="$_sudo nala purge"
else
alias search="apt-cache search"
alias install="$_sudo apt-get install --yes"
alias update="$_sudo apt-get update && $_sudo apt-get upgrade"
alias remove="$_sudo apt-get purge"
fi
alias unbreak="$_sudo dpkg --configure -a"
;;
*arch*)
if command_exists paru; then
alias search="paru -Ss"
alias install="paru -S --noconfirm"
alias update="paru -Syu"
alias remove="paru -R"
elif command_exists yay; then
alias search="yay -Ss"
alias install="yay -S --noconfirm"
alias update="yay -Syu"
alias remove="yay -R"
else
alias search="$_sudo pacman -Ss"
alias install="$_sudo pacman -S --noconfirm"
alias update="$_sudo pacman -Syu"
alias remove="$_sudo pacman -R"
fi
;;
*rhel* | *fedora*)
alias search="dnf search"
alias install="$_sudo dnf install -y --skip-missing"
alias update="$_sudo dnf update -y"
alias remove="$_sudo dnf remove -y"
;;
*suse*)
alias search="zypper search"
alias install="$_sudo zypper install --no-confirm"
alias update="$_sudo zypper update"
alias remove="$_sudo zypper remove"
;;
*alpine*)
alias install="$_sudo apk add"
alias update="$_sudo apk update && $_sudo apk upgrade"
alias remove="$_sudo apk del"
;;
*)
echo "Unsupported distro: $ID"
return 1
;;
esac
}
__alias__() {
__get_Packager__
alias please="sudo"
alias untar="tar -xf"
# ─< easier dir up >────────────────────────────────────────────────────────────────────────
alias ..="cd .."
# ─< weather >──────────────────────────────────────────────────────────────────────────────
alias www="curl wttr.in/Ulm"
# ─< colored ip >───────────────────────────────────────────────────────────────────
alias ip="ip --color=always"
# ─< check for rg >─────────────────────────────────────────────────────────────────────────
if command_exists rg; then
alias grep="rg --color=always"
else
alias grep="grep --color=always"
fi
# ─< linutil >────────────────────────────────────────────────────────────────────────────
alias linutil="curl -fsSL https://christitus.com/linux | sh"
alias "linutil-dev"="curl -fsSL https://christitus.com/linuxdev | sh"
# ─< telnet (starwars) >────────────────────────────────────────────────────────────────────
if command_exists telnet; then
alias starwars="telnet -a telehack.com"
fi
# ─< rsync >────────────────────────────────────────────────────────────────────────────────
if command_exists rsync; then
alias scp="rsync -avP"
alias cp="rsync -avP"
fi
[[ -f "$HOME/go/bin/lazygit" ]] &&
alias lazygit="$HOME/go/bin/lazygit" &&
alias lg="lazygit"
# ─< cli explorer >───────────────────────────────────────────────────────────────────────
if command_exists yazi; then
echo_info "yazi is the explorer of choice"
alias lf="yazi || ya pack -i"
# ─< yazi move when exit >────────────────────────────────────────────────────────────────
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
elif command_exists ranger; then
echo_info "ranger is the explorer of choice"
alias lf="ranger"
elif command_exists lf; then
echo_info "lf is the explorer of choice"
fi
# ─< colorized ls >─────────────────────────────────────────────────────────────────────────
if command_exists exa; then
alias ls="exa --icons -l --git"
alias l="exa --long --no-filesize --no-permissions --no-time --git --colour-scale --icons"
alias ll="exa --all --long --no-filesize --no-permissions --no-time --git --colour-scale --icons"
alias tree="exa --icons -l --tree"
elif command_exists lsd; then
alias ls="lsd -l -1 -h1 --almost-all --git"
alias l="lsd -1"
alias ll="lsd -1 --almost-all"
alias clearl="command clear && l"
alias tree="lsd --tree"
elif command_exists eza; then
alias ls="eza --icons --long --git"
alias l="eza --icons -l"
alias ll="eza --icons -laa"
alias tree="eza --icons -l --tree"
else
alias ls="ls --color=always -lAph"
alias l="ls --color=always -lph -w1"
alias ll="ls --color=always -lph"
fi
# ─< t stands for trash(-cli) >───────────────────────────────────────────────────────────────
if command_exists trash; then
alias rm="trash"
alias t="trash"
elif command_exists trash-cli; then
alias rm="trash-cli"
alias t="trash-cli"
else
echo_error "-- You do not have trash or trash-cli installed! Your 'rm' will be permanent! --"
fi
# ─< bat alias >────────────────────────────────────────────────────────────────────────────
if command_exists batcat; then
alias cat="batcat --color=always -p --paging=never"
alias less="batcat --paging always --color=always"
# alias gd="batcat --diff"
elif command_exists bat; then
alias cat="bat --color=always -p"
alias less="bat --paging always --color=always"
# alias gd="bat --diff"
fi
# ─< wireshark / termshark alias >────────────────────────────────────────────────────────
if command_exists termshark; then
alias ws="$_sudo termshark"
fi
# ─< fastfetch >────────────────────────────────────────────────────────────────────────────
if command_exists fastfetch; then
alias ff="fastfetch"
alias clearff="command clear & fastfetch"
alias clearf="command clear & fastfetch"
if fastfetch --config os >/dev/null 2>&1; then
alias f="fastfetch --config os"
else
git clone https://git.k4li.de/mirrors/fastfetch.git "$HOME/.local/share/fastfetch" >/dev/null 2>&1
exec "$SHELL"
fi
fi
# ─< d stands for docker >──────────────────────────────────────────────────────────────────
if command_exists docker; then
alias up="docker compose up"
alias down="docker compose down"
alias pull="docker compose pull"
alias d="docker"
alias dr="docker run --rm -it"
alias drs="docker compose down && docker compose up -d --remove-orphans --force-recreate"
alias ds="docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dcs="docker compose ps -a --format 'table {{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dl="docker compose logs -f"
alias dc="docker compose"
alias appupdate="docker compose pull && docker compose up -d --force-recreate"
fi
# ─< g stands for GIT >─────────────────────────────────────────────────────────────────────
if command_exists git; then
alias g="git"
alias gs="git status -sb"
alias gsl="git status"
alias gm='git checkout main && git merge'
alias gc="git clone --recurse-submodule"
gcl() {
if [ -z "$2" ]; then
git clone --depth=1 "https://github.com/$1"
else
git clone --depth=1 "https://github.com/$1" "$2"
fi
}
gck() {
if [ -z "$2" ]; then
git clone --recurse-submodules --depth=1 "https://git.k4li.de/$1"
else
git clone --recurse-submodules --depth=1 "https://git.k4li.de/$1" "$2"
fi
}
gcs() {
if [ -z "$2" ]; then
git clone --recurse-submodules --depth=1 "git@git.k4li.de:$1"
else
git clone --recurse-submodules --depth=1 "git@git.k4li.de:$1" "$2"
fi
}
alias gd="git diff"
alias ga="gd $1 && git add"
alias gp="git pull --recurse-submodule"
alias gms='git maintenance start'
alias gsu="git submodule foreach git pull && git add . && git commit -m ' updated 📌submodules' && echo '-- Committed changes, pushing now..' && sleep 1 && git push"
alias gcm="git commit -m"
alias gpu="git push --recurse-submodule=on-demand"
if command_exists lazygit; then
alias lg="lazygit"
fi
fi
alias inst_lazydocker="curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash"
# Function to determine which Neovim command to use
choose_nvim() {
if [ -n "$TMUX" ]; then
# If inside an active tmux session, use nvim
echo "command nvim"
return
elif [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ]; then
# If in a graphical environment, use Neovide
if command_exists neovide; then
echo "neovide --fork"
return
fi
fi
# Default to nvim
echo "command nvim"
}
# Set up Neovim aliases based on environment
if command_exists nvim; then
alias cnvim="command nvim"
alias nvim="$(choose_nvim)"
if [ -d "$HOME/.config/nvchad" ]; then
alias nvchad='NVIM_APPNAME="nvchad" command nvim'
alias neochad='NVIM_APPNAME="nvchad" neovide --fork'
fi
fi
# Tmux session manager
if command_exists tmux; then
ta() {
if tmux list-sessions >/dev/null 2>&1; then
echo "-- tmux session active! | Connecting to active session --"
sleep 0.3
tmux attach
else
echo "-- No tmux session found! | Creating one --"
sleep 0.3
tmux
fi
}
alias ts="tmux source $HOME/.tmux.conf"
fi
}
_coding_() {
# ─< h stands for HUGO >──────────────────────────────────────────────────────────────────
if command_exists hugo; then
alias h='hugo'
alias hs='hugo server -D --noHTTPCache --disableFastRender' # --bind "$(get_ip)"'
fi
# ─< c stands for bin/cake >──────────────────────────────────────────────────────────────
# alias cake='bin/cake'
# alias c='cake'
# alias cs='c server -p 1313'
# ─< VSCodium >─────────────────────────────────────────────────────────────────────────────
if command_exists codium; then
alias code="codium"
export EDITOR="codium"
fi
cursor_exe="/mnt/c/Users/piecka/AppData/Local/Programs/cursor/Cursor.exe"
if [ -e "$cursor_exe" ]; then
alias code="$cursor_exe"
fi
# Function to get the IP address
get_ip() {
ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1
}
if command_exists composer; then
alias laravel_new="composer create-project laravel/laravel"
fi
# Check if php is available, then create the alias
if command_exists php; then
alias phprun="php artisan serve --host=$(get_ip) --port=8000"
fi
# Check if npm is available, then create the alias
if command_exists npm; then
npmrun() {
npmrun_help() {
echo "Usage: npmrun [environment] [optional:port]"
echo " environment: The npm environment you want to run (e.g. dev)"
echo " port: Port to use (default: 8000)"
return
}
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
npmrun_help
return
fi
local env="$1"
local port="${2:-8080}"
npm run "$env" -- --host="$(get_ip)" --port="$port"
}
fi
}
__sources__() {
if [ -e "$HOME/.zshenv" ]; then
echo_info "Loadet zshenv"
. "$HOME/.zshenv"
@ -94,7 +440,7 @@ _sources() {
local sourceDir="$HOME/.zsh"
local sourceOptions=(
"defaults"
# "defaults"
"plugins"
"installs"
)
@ -108,25 +454,67 @@ _sources() {
done
}
_end() {
__defaults__() {
# 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
}
__end__() {
if command_exists fastfetch; then
clear &&
fastfetch
else
echo_warning "fastfetch is not installed.."
fi
if command_exists cowsay; then
alias clear='clear && cowsay -f tux "$(uptime --pretty)"'
cowsay -f tux "$(uptime --pretty)"
else
echo_warning "cowasy is not installed.."
fi
__shell_qol__
error_log
}
main() {
proxy
_init
_sources
_end
__defaults__
__alias__
__sources__
__end__
}
if check_root; then