dotfiles

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

.zshrc (2079B)


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