From 22092f778695eb1505c624d3e155dd3ecbd6b046 Mon Sep 17 00:00:00 2001 From: Yax Date: Sat, 2 May 2026 16:55:13 +0200 Subject: [PATCH] CLean and fix things --- dot_zshrc.tmpl | 69 ++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 72ac5c9..cce6525 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -7,9 +7,6 @@ autoload -Uz _zi (( ${+_comps} )) && _comps[zi]=_zi # end of zi init -# init completion -autoload -Uz compinit && compinit - # register multiple hooks #autoload -Uz add-zsh-hook @@ -20,10 +17,6 @@ bindkey -v # If you come from bash you might have to change your $PATH. export PATH=$HOME/bin:$HOME/.local/bin:$PATH -if [[ -f "$HOME/.zshrc.local" ]]; then - source "$HOME/.zshrc.local" -fi - zi snippet OMZL::history.zsh zi snippet OMZL::directories.zsh @@ -33,7 +26,14 @@ zi light spaceship-prompt/spaceship-prompt zi light zsh-users/zsh-syntax-highlighting zi is-snippet wait lucid for \ - OMZP::fzf + OMZP::fzf + +# init completion (after plugins so all completions are registered) +autoload -Uz compinit && compinit + +if [[ -f "$HOME/.zshrc.local" ]]; then + source "$HOME/.zshrc.local" +fi export FAVORITE_COMMAND1="{{ .tmux_favorite1 }}" export FAVORITE_COMMAND2="{{ .tmux_favorite2 }}" @@ -73,11 +73,11 @@ chpwd() { # Editor # --------------------------------------------------------------------------- -if hash nvim 2>/dev/null; then +if command -v nvim &>/dev/null; then export EDITOR=nvim -elif hash vim 2>/dev/null; then +elif command -v vim &>/dev/null; then export EDITOR=vim -elif hash vi 2>/dev/null; then +elif command -v vi &>/dev/null; then export EDITOR=vi else export EDITOR=nano @@ -95,21 +95,17 @@ alias vi=$EDITOR if command -v tmux &>/dev/null; then alias ta='tmux attach' - alias tkill="for s in \$(tmux list-sessions | awk -F ':' '{print \$1}' | fzf); do - tmux kill-session -t \$s; - done" -fi + tkill() { + local session + session=$(tmux list-sessions | awk -F ':' '{print $1}' | fzf) && tmux kill-session -t "$session" + } + set_tmux_title() { + tmux rename-window "$1" + } -# Function to set tmux window title -function set_tmux_title { - if [[ -n "$TMUX" ]]; then - tmux rename-window "$1" - fi -} - -# SSH wrapper to change the tmux title locally -function ssh() { + # SSH wrapper to change the tmux title locally + ssh() { if [[ -n "$TMUX" ]]; then # Save the original tmux window title original_title=$(tmux display-message -p '#W') @@ -126,15 +122,8 @@ function ssh() { set_tmux_title "$original_title" tmux set-window-option automatic-rename on fi -} - -export ZSH_TMUX_AUTOSTART=false -export ZSH_TMUX_AUTOSTART_ONCE=false -export ZSH_TMUX_AUTOCONNECT=true -export ZSH_TMUX_CONFIG=$HOME/.tmux.conf -export ZSH_TMUX_DEFAULT_SESSION_NAME=build - -#zi snippet OMZP::tmux + } +fi # --------------------------------------------------------------------------- # Fzf @@ -157,8 +146,16 @@ fi # Sesh / Zoxide # --------------------------------------------------------------------------- -alias t='sesh connect $(sesh list | fzf)' -eval "$(zoxide init zsh)" +if command -v sesh &>/dev/null; then + alias t='sesh connect $(sesh list | fzf)' +else + echo "warning: sesh is not installed" >&2 +fi +if command -v zoxide &>/dev/null; then + eval "$(zoxide init zsh)" +else + echo "warning: zoxide is not installed" >&2 +fi # --------------------------------------------------------------------------- # Maven @@ -174,7 +171,7 @@ if command -v mvn &>/dev/null; then alias mvnd='m -Dmaven.test.skip -Dmaven.javadoc.skip=true deploy -P profile-nexus' alias mvni='m -Dmaven.test.skip -Dmaven.javadoc.skip=true clean install' - function mbump() { + mbump() { if [ $# -eq 0 ]; then echo "Usage: mbump (means -SNAPSHOT) or mbump (kind is R or S)" else