Linux 效率工具
2026/6/12大约 3 分钟
~/.zshrc
# ── Completion ──────────────────────────────────────────────────
autoload -Uz compinit
compinit
if command -v dircolors >/dev/null 2>&1; then
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
fi
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion::complete:*' gain-privileges 1
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin
# ── History ─────────────────────────────────────────────────────
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory
setopt histignorealldups
setopt histignorespace
setopt inc_append_history
setopt share_history
# ── Plugins ─────────────────────────────────────────────────────
[[ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]] \
&& source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
[[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] \
&& source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[[ -f /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh ]] \
&& source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
# history-substring-search
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# ── Command-not-found hook ──────────────────────────────────────
source /usr/share/doc/pkgfile/command-not-found.zsh 2>/dev/null
# ── Prompt ──────────────────────────────────────────────────────
command -v starship >/dev/null 2>&1 && eval "$(starship init zsh)"
# ── Integrations ────────────────────────────────────────────────
command -v direnv >/dev/null 2>&1 && eval "$(direnv hook zsh)"
command -v zoxide >/dev/null 2>&1 && eval "$(zoxide init zsh)"
# ── Aliases ─────────────────────────────────────────────────────
command -v eza >/dev/null 2>&1 && alias ls="eza --icons=auto" \
&& alias ll="eza -la --icons=auto --git" \
&& alias lt="eza --tree"
command -v bat >/dev/null 2>&1 && alias cat="bat"
command -v rg >/dev/null 2>&1 && alias grep="rg"
command -v fd >/dev/null 2>&1 && alias find="fd"
alias gs="git status"
alias ga="git add"
alias gc="git commit -m"
alias gp="git push"
alias rm="rm -i"~/.config/starship.toml
[character]
success_symbol = "[➜](bold green)"
error_symbol = "[➜](bold red)"
[directory]
truncation_length = 4
truncate_to_repo = false~/.vimrc
" ── Basic ──────────────────────────────────────────────────────
set nocompatible " use Vim over vi settings
filetype plugin indent on " enable filetype detection, plugins, indent
syntax on " syntax highlighting
" ── Appearance ─────────────────────────────────────────────────
set number " absolute line numbers
set relativenumber " relative line numbers (hybrid with number)
set cursorline " highlight current line
set showmatch " briefly jump to matching bracket
set showcmd " show incomplete commands in statusline
set ruler " show cursor position
set laststatus=2 " always show status line
set scrolloff=5 " keep 5 lines of context above/below cursor
set termguicolors " true color support
" invisible characters
set list
set listchars=tab:»·,trail:·,precedes:«,extends:»
" ── Editing ────────────────────────────────────────────────────
set backspace=indent,eol,start " backspace over everything
set whichwrap=b,s,<,>,[,],h,l " arrow keys wrap across line boundaries
set expandtab " spaces instead of tabs
set tabstop=4 " tab width
set softtabstop=4 " soft tab width
set shiftwidth=4 " indent width
set autoindent " copy indent from previous line
set textwidth=0 " don't hard-wrap lines
set pastetoggle=<F11> " F11 toggles paste mode
" ── Search ─────────────────────────────────────────────────────
set ignorecase " case-insensitive search
set smartcase " override ignorecase when uppercase present
set incsearch " incremental search as you type
set hlsearch " highlight all matches
" clear search highlight with <leader>nh
nnoremap <silent> <leader>nh :nohlsearch<CR>
" ── Mouse ──────────────────────────────────────────────────────
set mouse=a " enable mouse in all modes
" ── Clipboard ──────────────────────────────────────────────────
set clipboard=unnamedplus " use system clipboard (+ register)
" ── Window splits ──────────────────────────────────────────────
set splitright " new vertical splits open to the right
set splitbelow " new horizontal splits open below
" ── Buffers ────────────────────────────────────────────────────
set hidden " hide buffers without saving
" ── History ────────────────────────────────────────────────────
set history=200 " remember 200 Ex commands and search patterns
" ── Quiet ──────────────────────────────────────────────────────
set noerrorbells " no bell for errors
set visualbell " use visual bell instead of audible
set t_vb= " but do nothing on visual bell (disable flash)
" ── Backup / swap files ────────────────────────────────────────
set nobackup " don't keep backup files
set noswapfile " don't create swap files
" ── Key timeout ────────────────────────────────────────────────
set ttimeoutlen=100 " 100ms timeout for key codes (faster response)
" ── Spell check ────────────────────────────────────────────────
set spell " enable spell checking
set spelllang=en_us " use American English dictionary
set spellsuggest=best,10 " show top 10 suggestions
" ── Useful mappings ────────────────────────────────────────────
" strip trailing whitespace
nnoremap <silent> ;tr :%s/\s\+$//<CR>
vnoremap <silent> ;tr :s/\s\+$//<CR>
" ── Autocommands ───────────────────────────────────────────────
" return to last edit position when reopening a file
augroup vimStartup
autocmd!
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
augroup END
" ── DiffOrig command ───────────────────────────────────────────
" show diff of current buffer against the file on disk
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif