Last active
December 16, 2025 12:44
-
-
Save qzchenwl/e858f2d0fc649a3cd2c64cc809d0f0ca to your computer and use it in GitHub Desktop.
zshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 0. Homebrew | |
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| # 1. CLI 工具(按你现在的 brew list 精简出来的) | |
| brew install aichat bat btop eza fd ffmpeg fzf git-delta mise neovim procs ripgrep starship zoxide | |
| # 2. Nerd Font | |
| brew install --cask font-jetbrains-mono-nerd-font | |
| # 然后在终端设置里选这个字体 | |
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [tools] | |
| gradle = "8.10.2" | |
| java = "17" | |
| node = "20" | |
| python = "3.11" | |
| maven = "latest" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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