Skip to content

Instantly share code, notes, and snippets.

@qzchenwl
Last active March 24, 2026 11:22
Show Gist options
  • Select an option

  • Save qzchenwl/e858f2d0fc649a3cd2c64cc809d0f0ca to your computer and use it in GitHub Desktop.

Select an option

Save qzchenwl/e858f2d0fc649a3cd2c64cc809d0f0ca to your computer and use it in GitHub Desktop.
zshrc
[alias]
# status
s = status -sb
st = status
# branch / checkout
br = branch
co = checkout
sw = switch
# commit
ci = commit
cm = commit -m
ca = commit --amend
cane = commit --amend --no-edit
# add / restore
a = add
aa = add -A
unstage = restore --staged
discard = restore
# diff
d = diff
ds = diff --staged
# log(重点:替代 git lk / git lg)
lg = log --graph --decorate --oneline
lk = log --stat --oneline
ll = log --pretty=format:'%C(yellow)%h%Creset %C(blue)%ad%Creset %s %C(green)(%an)%Creset' --date=short
# misc
cur = branch --show-current
[user]
useConfigOnly = true
# agent-deck configuration
# agent-deck-tmux-config-version: 2
# Added by agent-deck installer - 2026-03-12
# https://github.com/asheshgoplani/agent-deck
# Terminal with true color support
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm*:Tc:smcup@:rmcup@"
set -ag terminal-overrides ",*256col*:Tc"
# Performance
set -sg escape-time 0
set -g history-limit 500000
# Mouse support (scroll + drag-to-copy)
set -g mouse on
# Auto-enter copy-mode when scrolling up (critical for WSL compatibility)
# This handles: 1) apps with mouse support, 2) already in copy-mode, 3) normal pane
bind-key -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
# Scroll bindings in copy-mode (both vi and emacs modes)
bind-key -T copy-mode-vi WheelUpPane send-keys -X scroll-up
bind-key -T copy-mode-vi WheelDownPane send-keys -X scroll-down
bind-key -T copy-mode WheelUpPane send-keys -X scroll-up
bind-key -T copy-mode WheelDownPane send-keys -X scroll-down
# Clipboard integration (drag-to-copy)
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
# End agent-deck configuration
# ---------------------------------
# Prefix: use Ctrl-a
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Use vi keys in copy mode
setw -g mode-keys vi
# Easier config reload
bind r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded"
# Better splits: keep current path
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Resize panes quickly
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Easier pane switching with prefix + hjkl
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Maximize / restore current pane
# default tmux already supports prefix + z
# keep it as-is
# Easier window navigation
bind Tab last-window
bind n next-window
bind p previous-window
# -------------------------
# Smart nvim/vim pane navigation
# -------------------------
# If current pane is running vim/nvim/vimdiff/nvim -d style workflow,
# send Ctrl-h/j/k/l to editor.
# Otherwise move between tmux panes.
bind -n C-h if-shell "tmux display-message -p '#{pane_current_command}' | grep -iqE '^(vim|nvim|vimdiff)$'" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "tmux display-message -p '#{pane_current_command}' | grep -iqE '^(vim|nvim|vimdiff)$'" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "tmux display-message -p '#{pane_current_command}' | grep -iqE '^(vim|nvim|vimdiff)$'" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "tmux display-message -p '#{pane_current_command}' | grep -iqE '^(vim|nvim|vimdiff)$'" "send-keys C-l" "select-pane -R"
# -------------------------
# Copy mode improvements
# -------------------------
# Begin selection with v in copy-mode-vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
# Copy selection with y in copy-mode-vi
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
# -------------------------
# Quality-of-life aliases
# -------------------------
# New window in current path
bind c new-window -c "#{pane_current_path}"
# Swap panes
bind > swap-pane -D
bind < swap-pane -U
# Kill current pane with uppercase X
bind X kill-pane
# Kill current window with uppercase &
bind "&" confirm-before -p "Kill window #W? (y/n)" kill-window
# pane title bar
set -g pane-border-status top
# inactive display number,active display dot
set -g pane-border-format '#{?pane_active,#[fg=colour39]● ,#[fg=colour244]#P }'
# border
set -g pane-border-style 'fg=colour240'
set -g pane-active-border-style 'fg=colour39'
eval "$(mise activate zsh)"
eval "$(starship init zsh)"
eval "$(zoxide init zsh)"
# Editor
export EDITOR=nvim
# Android SDK paths
export ANDROID_HOME="$HOME/Library/Android/sdk"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH"
# Use mise-managed Java (derive from active java binary)
export JAVA_HOME="$(dirname "$(dirname "$(mise which java 2>/dev/null)")")"
[ -d "$JAVA_HOME" ] && export PATH="$JAVA_HOME/bin:$PATH"
##### 非交互 shell 早退(优化脚本性能) #####
# 比如:zsh -c 'cmd' 时,只需要上面的环境变量,无需历史/fzf/zinit/AI
[[ $- != *i* ]] && return
##### zsh 历史增强配置 #####
# 历史文件位置与大小
HISTFILE=~/.zsh_history
HISTSIZE=200000
SAVEHIST=200000
# 历史写入策略
setopt APPEND_HISTORY # 追加写入,不覆盖历史
setopt INC_APPEND_HISTORY # 实时写入,每执行一条命令即写入文件
setopt SHARE_HISTORY # 多 Tab/窗口共享历史(自动合并)
setopt HIST_FCNTL_LOCK # 防止极端情况下历史并发写入冲突
# 历史质量优化
setopt HIST_IGNORE_DUPS # 忽略连续重复命令
setopt HIST_REDUCE_BLANKS # 自动清理多余空白
setopt HIST_SAVE_NO_DUPS # 保存历史时不写入重复项
setopt HIST_VERIFY # 历史命令执行前可编辑,而不是立即执行
# 安全性增强:以空格开头的命令不会写入历史(用于密码/token)
setopt HIST_IGNORE_SPACE
# 可选:关闭 EXTENDED_HISTORY(如果你不需要时间戳)
# unsetopt EXTENDED_HISTORY
# Ctrl + X, Ctrl + E 打开编辑器编辑命令行
autoload -z edit-command-line
zle -N edit-command-line
bindkey "^X^E" edit-command-line
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
autoload -Uz compinit
compinit
### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
print -P "%F{33} %F{34}Installation successful.%f%b" || \
print -P "%F{160} The clone has failed.%f%b"
fi
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zdharma-continuum/zinit-annex-as-monitor \
zdharma-continuum/zinit-annex-bin-gem-node \
zdharma-continuum/zinit-annex-patch-dl \
zdharma-continuum/zinit-annex-rust
### End of Zinit's installer chunk
##### 使用 zinit 实际加载插件 #####
# 自动建议(右侧灰色提示)
zinit light zsh-users/zsh-autosuggestions
# 语法高亮(命令对错一眼看出来)
zinit light zsh-users/zsh-syntax-highlighting
# Tab 补全
zinit light Aloxaf/fzf-tab
zstyle ':fzf-tab:complete:*' fzf-preview 'bat --color=always --style=plain --line-range=:300 -- "$item" 2>/dev/null'
##### 常用 alias(按需开启) #####
alias ls='eza --icons'
alias ll='eza -lha --icons'
alias cat='bat'
alias grep='rg'
alias ..='cd ..'
alias ...='cd ../..'
alias vim='nvim'
# 0. Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 1. CLI 工具(按你现在的 brew list 精简出来的)
brew install bat btop eza fd ffmpeg fzf git-delta mise neovim procs ripgrep starship zoxide difftastic
# 2. Nerd Font
brew install --cask font-jetbrains-mono-nerd-font
# 然后在终端设置里选这个字体
brew install font-lxgw-wenkai # https://github.com/lxgw/LxgwWenKai
# 3. zinit
bash -c "$(curl -fsSL https://git.io/zinit-install)"
# 4. 覆盖 ~/.zshrc 为上面那份模板
nano ~/.zshrc
source ~/.zshrc
# 5. 可选:Neovim LazyVim
git clone https://github.com/LazyVim/starter ~/.config/nvim
[tools]
gradle = "8.10.2"
java = "17"
node = "20"
python = "3.11"
maven = "latest"
[python]
disabled = true
[nodejs]
disabled = true
[ruby]
disabled = true
[golang]
disabled = true
[rust]
disabled = true
[java]
disabled = true
[kotlin]
disabled = true
[dotnet]
disabled = true
[php]
disabled = true
[perl]
disabled = true
[lua]
disabled = true
[haskell]
disabled = true
[scala]
disabled = true
[elixir]
disabled = true
[zig]
disabled = true
[swift]
disabled = true
[nim]
disabled = true
[dart]
disabled = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment