simplify zsh config

This commit is contained in:
Tomas Mirchev 2025-10-12 06:48:06 +02:00
parent d45a3971fd
commit e48a477c02
7 changed files with 42 additions and 144 deletions

View File

@ -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",

41
config/shared/zsh Normal file
View File

@ -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 */'

View File

@ -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'

View File

@ -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

View File

@ -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) $ '

View File

@ -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"

View File

@ -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