From e48a477c0296ce3f87f719dbef0b1a8f57186e36 Mon Sep 17 00:00:00 2001 From: Tomas Mirchev Date: Sun, 12 Oct 2025 06:48:06 +0200 Subject: [PATCH] simplify zsh config --- config.json | 11 +------ config/shared/zsh | 41 +++++++++++++++++++++++ config/shared/zsh_config/aliases | 47 -------------------------- config/shared/zsh_config/keybindings | 15 --------- config/shared/zsh_config/prompt | 15 --------- config/shared/zsh_config/zshrc | 49 ---------------------------- config/shared/zsh_root | 8 ----- 7 files changed, 42 insertions(+), 144 deletions(-) create mode 100644 config/shared/zsh delete mode 100644 config/shared/zsh_config/aliases delete mode 100644 config/shared/zsh_config/keybindings delete mode 100644 config/shared/zsh_config/prompt delete mode 100644 config/shared/zsh_config/zshrc delete mode 100644 config/shared/zsh_root diff --git a/config.json b/config.json index b351a41..a92e652 100644 --- a/config.json +++ b/config.json @@ -28,16 +28,10 @@ }, "zsh": { "link": { - "from": "shared/zsh_root", + "from": "shared/zsh", "to": "~/.zshrc" } }, - "zsh_config": { - "link": { - "from": "shared/zsh_config", - "to": "~/.config/zsh" - } - }, "tmux": { "link": { "from": "shared/tmux", @@ -72,7 +66,6 @@ "environments": { "macos": [ "zsh", - "zsh_config", { "package": "bin", "link": { @@ -105,7 +98,6 @@ } ], "linux-vm": [ - "zsh_config", { "package": "zsh", "install": "sudo apt install -y zsh", @@ -134,7 +126,6 @@ "bin" ], "linux-dev": [ - "zsh_config", { "package": "zsh", "install": "sudo apt install -y zsh", diff --git a/config/shared/zsh b/config/shared/zsh new file mode 100644 index 0000000..94f3521 --- /dev/null +++ b/config/shared/zsh @@ -0,0 +1,41 @@ +export PATH="$PATH:$HOME/bin" +export LANG=en_US.UTF-8 +export LC_CTYPE=en_US.UTF-8 +export LC_COLLATE=C + +KEYTIMEOUT=1 +HISTFILE=$HOME/.zsh_history +HISTSIZE=10000 +SAVEHIST=10000 + +setopt auto_cd interactive_comments prompt_subst +setopt append_history hist_ignore_dups hist_ignore_all_dups hist_reduce_blanks + +autoload -Uz compinit +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case-insensitive +zstyle ':completion:*' use-cache on +zstyle ':completion:*' cache-path ~/.zsh/cache +compinit + +git_prompt_info() { + if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + local branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD) + echo " %F{green}($branch)%f" + fi +} +PROMPT='%n@%m%f %F{blue}%~%f$(git_prompt_info) $ ' + +autoload -U up-line-or-beginning-search down-line-or-beginning-search +zle -N up-line-or-beginning-search +zle -N down-line-or-beginning-search +bindkey '^[[A' up-line-or-beginning-search +bindkey '^[OA' up-line-or-beginning-search +bindkey '^[[B' down-line-or-beginning-search +bindkey '^[OB' down-line-or-beginning-search +bindkey '^U' backward-kill-line + +# alias ls='ls --color=auto --group-directories-first' +alias ls='ls --color=auto' +alias ll='ls -lF' +alias lla='ll -a' +alias ld='ls -ld */' diff --git a/config/shared/zsh_config/aliases b/config/shared/zsh_config/aliases deleted file mode 100644 index 3460d96..0000000 --- a/config/shared/zsh_config/aliases +++ /dev/null @@ -1,47 +0,0 @@ -# ----------------------------- -# OS-specific aliases for ls -# ----------------------------- -OS_TYPE=$(uname) -if [[ "$OS_TYPE" == "Linux" ]]; then - alias ls='ls --color=auto --group-directories-first' -elif [[ "$OS_TYPE" == "Darwin" ]]; then - alias ls='ls --color=auto' -fi - -alias ll='ls -lF' -alias lla='ll -a' -alias ld='ls -ld */' - -# ----------------------------- -# Vim / Neovim -# ----------------------------- -if command -v nvim >/dev/null 2>&1; then - alias vim='nvim' -fi - -# ----------------------------- -# Git aliases -# ----------------------------- -alias g='git' -alias ga='git add' -alias gaa='git add --all' -alias gb='git branch' -alias gcm='git commit -m' -alias gam='git commit -am' -alias gco='git checkout' -alias gd='git diff' -alias gf='git fetch' -alias gl='git pull' -alias gp='git push' -alias gst='git status' -alias glg='git log --graph --oneline --decorate --all' -alias gm='git merge' -alias grb='git rebase' -alias grs='git reset' -alias grv='git remote -v' -alias tree='tree -I node_modules' - -# ----------------------------- -# Other -# ----------------------------- -alias k='kubectl' diff --git a/config/shared/zsh_config/keybindings b/config/shared/zsh_config/keybindings deleted file mode 100644 index 031c623..0000000 --- a/config/shared/zsh_config/keybindings +++ /dev/null @@ -1,15 +0,0 @@ -# ----------------------------- -# ZLE functions -# ----------------------------- -autoload -U up-line-or-beginning-search -autoload -U down-line-or-beginning-search -zle -N up-line-or-beginning-search -zle -N down-line-or-beginning-search - -bindkey '^[[A' up-line-or-beginning-search -bindkey '^[OA' up-line-or-beginning-search -bindkey '^[[B' down-line-or-beginning-search -bindkey '^[OB' down-line-or-beginning-search - -bindkey '^U' backward-kill-line - diff --git a/config/shared/zsh_config/prompt b/config/shared/zsh_config/prompt deleted file mode 100644 index 2610971..0000000 --- a/config/shared/zsh_config/prompt +++ /dev/null @@ -1,15 +0,0 @@ -# ----------------------------- -# Git prompt function -# ----------------------------- -git_prompt_info() { - if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then - local branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD) - echo " %F{green}($branch)%f" - fi -} - -# ----------------------------- -# Set prompt -# ----------------------------- -PROMPT='%n@%m%f %F{blue}%~%f$(git_prompt_info) $ ' - diff --git a/config/shared/zsh_config/zshrc b/config/shared/zsh_config/zshrc deleted file mode 100644 index 011e3f7..0000000 --- a/config/shared/zsh_config/zshrc +++ /dev/null @@ -1,49 +0,0 @@ -# ----------------------------- -# PATH -# ----------------------------- -export PATH="$PATH:$HOME/bin" -export KEYTIMEOUT=1 - -# ----------------------------- -# Locales -# ----------------------------- -export LANG=en_US.UTF-8 -export LC_CTYPE=en_US.UTF-8 -export LC_COLLATE=C - -# ----------------------------- -# Autocomplete -# ----------------------------- -autoload -Uz compinit && compinit -zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case insensitive - -# ----------------------------- -# Shell options -# ----------------------------- -setopt autocd -setopt share_history -setopt interactivecomments -setopt PROMPT_SUBST # Enable dynamic prompt expansion - -# ----------------------------- -# Disable conflicting builtins -# ----------------------------- -disable log - -# ----------------------------- -# History -# ----------------------------- -HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history -HISTSIZE=2000 -SAVEHIST=1000 -setopt HIST_IGNORE_ALL_DUPS - -# ----------------------------- -# Source modular components -# ----------------------------- -CONFIG_DIR="$HOME/.config/zsh" - -[ -f "$CONFIG_DIR/aliases" ] && source "$CONFIG_DIR/aliases" -[ -f "$CONFIG_DIR/prompt" ] && source "$CONFIG_DIR/prompt" -[ -f "$CONFIG_DIR/keybindings" ] && source "$CONFIG_DIR/keybindings" - diff --git a/config/shared/zsh_root b/config/shared/zsh_root deleted file mode 100644 index ad1a99e..0000000 --- a/config/shared/zsh_root +++ /dev/null @@ -1,8 +0,0 @@ -export EDITOR="nvim" -export VISUAL="nvim" -if [ -f "$HOME/.config/zsh/zshrc" ]; then - source "$HOME/.config/zsh/zshrc" -else - echo "Warning: ~/.config/zsh/zshrc not found, skipping custom Zsh configuration." -fi -