.zshrc (2484B)
1 # .zshrc 2 3 # History. 4 [[ ! -d "$XDG_CACHE_HOME/zsh" ]] && mkdir -p "$XDG_CACHE_HOME/zsh" 5 HISTFILE="$XDG_CACHE_HOME/zsh/zsh_histfile" 6 HISTSIZE=10000 7 SAVEHIST=10000 8 9 # Write history command-by-command, don't overwrite. 10 setopt INC_APPEND_HISTORY 11 12 # Treat '#', '~', and '^' as part of patterns for filename generation. 13 setopt EXTENDED_GLOB 14 15 # vi-mode. 16 bindkey -v 17 bindkey '^Y' push-line 18 bindkey '^R' history-incremental-search-backward 19 20 # Add zsh completion definition dirs. 21 fpath=("$HOME/.local/zsh/site-functions" "$ZDOTDIR/site-functions" "${fpath[@]}") 22 23 # Specify where compinstall writes cfg commands. Default, but saves checks. 24 zstyle ':compinstall' filename "$ZDOTDIR/.zshrc" 25 26 # Use menu-style autocompletion. 27 zstyle ':completion:*' menu select 28 29 # Initialize completion for current session. 30 autoload -Uz compinit && compinit 31 32 # Current VCS branch (for prompt). 33 vcs_branch() { 34 # If in a jj repo, indicate that we're in a repo. 35 if (( $+commands[jj] )) && jj root > /dev/null 2>&1; then 36 echo -n " ◉ " 37 return 38 fi 39 40 # If we're in a git repo, output the current branch name. 41 local branch 42 branch="$(git rev-parse --abbrev-ref HEAD 2> /dev/null)" 43 if [[ -n $branch ]]; then 44 echo -n " ($branch)" 45 fi 46 } 47 48 # Prompt. 49 setopt prompt_subst 50 autoload -Uz colors && colors 51 PROMPT='%{$fg[yellow]%}%T %{$fg[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%c%{$fg[yellow]%}$(vcs_branch)%{$reset_color%}%# ' 52 53 # Set TERM for known terminals, and as a fallback when specified term is 54 # unavailable. 55 term_bin="" 56 if [[ -e /proc/$PPID/cmdline ]]; then 57 term_bin="${$(</proc/$PPID/cmdline):t}" 58 fi 59 if [[ "$COLORTERM" == "gnome-terminal" ]] || \ 60 [[ "$term_bin" == gnome-terminal* ]] || \ 61 [[ "$TERM" == "xterm-256color-italic" && ! $(tput -T"$TERM" longname > /dev/null 2>&1) ]]; then 62 export TERM=xterm-256color 63 fi 64 unset term_bin 65 66 # Load path additions. 67 if [ -f "$XDG_CONFIG_HOME/zsh/paths" ]; then 68 . "$XDG_CONFIG_HOME/zsh/paths" 69 fi 70 71 # Load aliases. 72 if [ -f "$XDG_CONFIG_HOME/zsh/aliases" ]; then 73 . "$XDG_CONFIG_HOME/zsh/aliases" 74 fi 75 76 # Load colour support. 77 if [ -f "$XDG_CONFIG_HOME/zsh/colors" ]; then 78 . "$XDG_CONFIG_HOME/zsh/colors" 79 fi 80 81 # Load custom functions. 82 if [ -f "$XDG_CONFIG_HOME/zsh/functions" ]; then 83 . "$XDG_CONFIG_HOME/zsh/functions" 84 fi 85 86 # Load tools. 87 if [ -f "$XDG_CONFIG_HOME/zsh/tools" ]; then 88 . "$XDG_CONFIG_HOME/zsh/tools" 89 fi 90 91 # Source any machine-local config. 92 if [[ -f "$HOME/.local/config/zsh/zshrc" ]]; then 93 . "$HOME/.local/config/zsh/zshrc" 94 fi