From d92857428e43a0717fc0d283cec999e4aa7adfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Jane=C5=BEi=C4=8D?= Date: Mon, 9 Mar 2026 12:08:23 +0100 Subject: [PATCH] feat(zsh): idiomatically organise .zprofile .zshenv and .zshrc --- zsh/.zprofile | 6 +++++- zsh/.zshenv | 8 +++----- zsh/.zshrc | 24 +++++++++++++----------- zsh/aliases.zsh | 4 ++-- zsh/scripts.zsh | 5 +++-- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/zsh/.zprofile b/zsh/.zprofile index 8b13789..680433b 100644 --- a/zsh/.zprofile +++ b/zsh/.zprofile @@ -1 +1,5 @@ - +path=( + "$HOME/.local/bin" + "$GOPATH/bin" + $path +) diff --git a/zsh/.zshenv b/zsh/.zshenv index c9d1d77..5460e20 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -4,8 +4,8 @@ export XDG_CACHE_HOME="$HOME/.cache" export XDG_DATA_HOME="$HOME/.local/share" export XDG_STATE_HOME="$HOME/.local/state" -# ~/.local/bin -export PATH="$HOME/.local/bin:$PATH" +# deduplicate path +typeset -U path # editor export EDITOR=nvim @@ -13,14 +13,12 @@ export EDITOR=nvim # go export GOPATH="$XDG_DATA_HOME/go" export GOMODCACHE="$XDG_CACHE_HOME/go/mod" -export PATH="$GOPATH/bin:$PATH" # ggman export GGROOT="$HOME/git" - # name export NAME="Matej Janežič" -# starship nest config into a folder, default is ~/.config/startship.toml +# starship nest config into a folder, default is ~/.config/starship.toml export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship/config.toml" diff --git a/zsh/.zshrc b/zsh/.zshrc index 9103051..75a6028 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,15 +1,17 @@ -# zsh history file -export HISTFILE="$XDG_STATE_HOME/zsh/history" -export HISTSIZE=100 +# zsh history file +HISTFILE="$XDG_STATE_HOME/zsh/history" +HISTSIZE=10000 +SAVEHIST=10000 + +# gnupg +export GPG_TTY=$(tty) ## pre plugin load -# nvm -export NVM_COMPLETION=true -# zsh autosugestions -export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ffffff,bg=cyan,bold,underline" +# zsh autosuggestions +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ffffff,bg=cyan,bold,underline" # source antidote -source $ZDOTDIR/.antidote/antidote.zsh +source "$ZDOTDIR/.antidote/antidote.zsh" antidote load unsetopt autocd @@ -22,10 +24,10 @@ source "$ZDOTDIR/aliases.zsh" source "$ZDOTDIR/scripts.zsh" # completion -fpath=($ZDOTDIR/completions $fpath) +fpath=("$ZDOTDIR/completions" $fpath) autoload -Uz compinit -compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION -zstyle ':completion:*' cache-path $XDG_CACHE_HOME/zsh/zcompcache +compinit -d "$XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION" +zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache" eval "$(starship init zsh)" eval "$(direnv hook zsh)" diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index be55e56..6abab72 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -10,11 +10,11 @@ alias dp="docker ps --format 'table {{.Names}}\t{{.Ports}}'" alias dcp="docker compose ps --format 'table {{.Name}}\t{{.Ports}}'" # navigation -alias cdgit="cd $GGROOT" +alias cdgit='cd $GGROOT' # git alias gpo="git push origin" -alias gros="git reset origin/$(git_current_branch) --soft" +gros() { git reset "origin/$(git_current_branch)" --soft } alias gcan="git commit -v --amend --no-edit" alias glogaa="git log --oneline --graph --all --pretty=format:\"%C(auto)%h %C(blue)(%aL/%cL)%C(auto)%(decorate) %s%Creset\"" diff --git a/zsh/scripts.zsh b/zsh/scripts.zsh index 5dc979e..7225c0b 100644 --- a/zsh/scripts.zsh +++ b/zsh/scripts.zsh @@ -1,10 +1,11 @@ function tmux_attach { + local tmux_running tmux_running=$(pgrep tmux) - if ! [[ -z ${TMUX} ]]; then + if [[ -n ${TMUX} ]]; then echo "already attached; refreshing env" source <(tmux show-environment | sed -n 's/^\(.*\)=\(.*\)$/export \1="\2"/p') - return 1 + return 0 fi if [[ -z $tmux_running ]]; then