# --- # @author jianqun.me # @updated 2025-07-29 # --- # --- # Interactive Shell Check # --- case "$-" in *i* ) ;; * ) return ;; esac # --- # Zsh Autoload # --- autoload -Uz compinit && compinit autoload -Uz colors && colors # --- # Zsh History # --- setopt APPEND_HISTORY setopt HIST_IGNORE_ALL_DUPS setopt HIST_IGNORE_SPACE HISTFILE=~/.zsh_history HISTSIZE=1000 SAVEHIST=1000 # --- # Zsh Completion # --- zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*' menu select zstyle ':completion:*' special-dirs true # --- # Zsh Prompt # --- PROMPT="" PROMPT+="%B%F{white}[ at %f%b" PROMPT+="%B%F{green}%m%f%b" PROMPT+="%B%F{white} in %f%b" PROMPT+="%B%F{blue}%~%f%b" PROMPT+="%B%F{white} ]%f%b" PROMPT+=$'\n%# ' RPROMPT="" case "$TERM" in xterm* | rxvt* ) precmd() { print -Pn "\e[2 q" print -Pn "\e]0;[ at %m in %. ] %#\a" } ;; tmux* | screen* ) precmd() { print -Pn "\e[2 q" } ;; * ) ;; esac # --- # Zsh Keymaps # --- bindkey -e # --- # Zsh Aliases # --- alias ls='ls --classify=auto --group-directories-first --color=auto' alias grep='grep --color=auto' alias diff='diff --color=auto' alias ip='ip --color=auto' alias less='less -iMR --incsearch' alias more='more -e' alias rm='rm -I' alias cp='cp -i' alias mv='mv -i' alias ln='ln -i' alias df='df -h' alias du='du -h' alias free='free -h' alias tree='tree --dirsfirst' if [ -x "$(command -v sudo)" ]; then alias sudo='sudo ' if [ -x "$(command -v nvim)" ]; then alias sudoedit='sudo nvim -u ~/.config/nvim/init.lua' fi fi if [ -x "$(command -v doas)" ]; then alias doas='doas ' if [ -x "$(command -v nvim)" ]; then alias doasedit='doas nvim -u ~/.config/nvim/init.lua' fi fi if [ -f /etc/alpine-release ]; then alias ls='ls -F --group-directories-first --color=auto' unalias diff ip rm fi # --- # Dircolors # --- if [ -x "$(command -v dircolors)" ]; then if [ -r ~/.dircolors ]; then eval "$(dircolors -b ~/.dircolors)" else eval "$(dircolors -b)" fi fi # --- # Lesspipe.sh # --- if [ -x "$(command -v lesspipe)" ]; then eval "$(SHELL=/bin/sh lesspipe)" fi # --- # Fzf # --- if [ -x "$(command -v fzf)" ]; then source <(fzf --zsh) fi