# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi
# mode configuration for zsh-vim-mode, shown on the right (RPS1 stuff) MODE_INDICATOR_VIINS='%F{15}<%F{8}INSERT<%f' MODE_INDICATOR_VICMD='%F{10}<%F{2}NORMAL<%f' MODE_INDICATOR_REPLACE='%F{9}<%F{1}REPLACE<%f' MODE_INDICATOR_SEARCH='%F{13}<%F{5}SEARCH<%f' MODE_INDICATOR_VISUAL='%F{12}<%F{4}VISUAL<%f' MODE_INDICATOR_VLINE='%F{12}<%F{4}V-LINE<%f'
# Make it work with your existing RPS1 if it is set. Note the single quotes setopt PROMPT_SUBST RPS1='${MODE_INDICATOR_PROMPT} ${vcs_info_msg_0_}'
# configuration for zsh-auto-notify export AUTO_NOTIFY_THRESHOLD=20
# -M: verbose mode # -N: show line number # -s: squeeze blank lines to single blank line export LESS='-RMs' export PAGER=less export VISUAL=vi export LC_COLLATE='C' export LC_ALL="en_US.UTF-8" export LANG=en_US.UTF-8 export KEYTIMEOUT=30
# use nvim as man pager if [[ "$(command -v nvim)" ]]; then export EDITOR='nvim' export MANPAGER='nvim +Man!' export MANWIDTH=999 fi
setopt noclobber # Do not overwrite existing files by default setopt autocd # cd to a directory if only name is provided setopt correct_all # correct misspelled command setopt no_case_glob # case-insensitive globbing
setopt HIST_IGNORE_ALL_DUPS # do not put duplicated command into history list setopt HIST_SAVE_NO_DUPS # do not save duplicated command setopt HIST_REDUCE_BLANKS # remove unnecessary blanks setopt INC_APPEND_HISTORY_TIME # append command to history file immediately after execution setopt EXTENDED_HISTORY # record command start time
# let comments work in interactive shell setopt INTERACTIVE_COMMENTS
####################################################################### # custom alias # ####################################################################### alias zshconfig="nvim ~/.zshrc" alias grep="grep -E -n --color=auto" alias ls='ls -F --color=auto' alias less="less -m" alias hexdump='hexdump -C' alias ll="ls -l --color=auto" alias ldot='ls -d .??*' alias cp='nocorrect cp -i' alias mv='nocorrect mv -i' alias cls="clear" alias ls='exa' alias history="fc -l 1" # below alias taken from https://github.com/zimfw/history/blob/master/init.zsh alias history-stat="fc -ln 0 | awk '{print \$1}' | sort | uniq -c | sort -nr | head"
####################################################################### # key binding settings # ####################################################################### # Use vim key binding instead of the default emacs key binding # bindkey -v
# For terminal which can not understand home and end key on zsh shell # https://anjia0532.github.io/2017/09/10/zsh-home-end-keypad-not-work/ bindkey '^[[H' beginning-of-line bindkey '^[[F' end-of-line
# Note that we need to use compinit command after we add new completions to # some command or update the completion behavior. Instead of running the # command multiple times, running it at the end of the zshrc seems okay. compinit
if [[ $(uname) == "Darwin" ]]; then source .zshrc_mac else source .zshrc_linux fi
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh