dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

.zshrc (2550B)


      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 if [ -d ".homebrew/share/zsh/site-functions" ]; then
     22   fpath=("$HOME/.homebrew/share/zsh/site-functions" "${fpath[@]}")
     23 fi
     24 fpath=("$HOME/.local/zsh/site-functions" "$ZDOTDIR/site-functions" "${fpath[@]}")
     25 
     26 # Specify where compinstall writes cfg commands. Default, but saves checks.
     27 zstyle ':compinstall' filename "$ZDOTDIR/.zshrc"
     28 
     29 # Use menu-style autocompletion.
     30 zstyle ':completion:*' menu select
     31 
     32 # Initialize completion for current session.
     33 autoload -Uz compinit && compinit
     34 
     35 # Current VCS branch (for prompt).
     36 vcs_branch() {
     37   # If in a jj repo, indicate that we're in a repo.
     38   if (( $+commands[jj] )) && jj root > /dev/null 2>&1; then
     39     echo -n " ◉ "
     40     return
     41   fi
     42 
     43   # If we're in a git repo, output the current branch name.
     44   local branch
     45   branch="$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)"
     46   if [[ -n $branch ]]; then
     47     echo -n " ($branch)"
     48   fi
     49 }
     50 
     51 # Prompt.
     52 setopt prompt_subst
     53 autoload -Uz colors && colors
     54 PROMPT='%{$fg[yellow]%}%T %{$fg[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%c%{$fg[yellow]%}$(vcs_branch)%{$reset_color%}%# '
     55 
     56 # Set TERM for known terminals, and as a fallback when specified term is
     57 # unavailable.
     58 term_bin=""
     59 if [[ -e /proc/$PPID/cmdline ]]; then
     60   term_bin="${$(</proc/$PPID/cmdline):t}"
     61 fi
     62 if [[ "$COLORTERM" == "gnome-terminal" ]] || \
     63    [[ "$term_bin" == gnome-terminal* ]] || \
     64    [[ "$TERM" == "xterm-256color-italic" && ! $(tput -T"$TERM" longname > /dev/null 2>&1) ]]; then
     65   export TERM=xterm-256color
     66 fi
     67 unset term_bin
     68 
     69 # Load path additions.
     70 if [ -f "$XDG_CONFIG_HOME/zsh/paths" ]; then
     71   . "$XDG_CONFIG_HOME/zsh/paths"
     72 fi
     73 
     74 # Load aliases.
     75 if [ -f "$XDG_CONFIG_HOME/zsh/aliases" ]; then
     76   . "$XDG_CONFIG_HOME/zsh/aliases"
     77 fi
     78 
     79 # Load colour support.
     80 if [ -f "$XDG_CONFIG_HOME/zsh/colors" ]; then
     81   . "$XDG_CONFIG_HOME/zsh/colors"
     82 fi
     83 
     84 # Load custom functions.
     85 if [ -f "$XDG_CONFIG_HOME/zsh/functions" ]; then
     86   . "$XDG_CONFIG_HOME/zsh/functions"
     87 fi
     88 
     89 # Source any machine-local config.
     90 if [[ -f "$HOME/.local/config/zsh/zshrc" ]]; then
     91   . "$HOME/.local/config/zsh/zshrc"
     92 fi