Skip to content

Instantly share code, notes, and snippets.

@aereal
Created November 26, 2015 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aereal/f59f2d8710a3e8a90aab to your computer and use it in GitHub Desktop.
Save aereal/f59f2d8710a3e8a90aab to your computer and use it in GitHub Desktop.
# environment
export HOMEBREW_PATH=/usr/local
export GOPATH=$HOME/.go
path=(
$HOME/bin(N-/)
$HOME/.rbenv/shims(N-/)
$HOME/.plenv/shims(N-/)
$HOME/.ndenv/shims(N-/)
$GOPATH/bin(N-/)
$HOMEBREW_PATH/opt/coreutils/libexec/gnubin(N-/)
$HOMEBREW_PATH/bin(N-/)
/usr/bin(N-/)
/usr/sbin(N-/)
/bin(N-/)
/sbin(N-/)
)
typeset -U manpath
manpath=(
$HOMEBREW_PATH/share/man(N-/)
$HOMEBREW_PATH/opt/coreutils/libexec/gnuman(N-/)
/usr/share/man(N-/)
)
typeset -Ua fpath
fpath=(
$ZSH_HOME/functions(N-/)
$HOMEBREW_PATH/share/zsh-completions(N-/)
$HOMEBREW_PATH/share/zsh/site-functions(N-/)
$HOMEBREW_PATH/share/zsh/functions(N-/)
$fpath
)
export PAGER=less
export LESS='--LONG-PROMPT --RAW-CONTROL-CHARS'
export REPORTTIME=1
setopt extended_glob
# history
HISTFILE=$HOME/.zsh_history
HISTSIZE=10000000
SAVEHIST=$HISTSIZE
set \
extended_history \
hist_ignore_dups \
hist_ignore_space \
inc_append_history \
share_history \
no_flow_control
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey -v "^N" history-beginning-search-forward-end
bindkey -v "^P" history-beginning-search-backward-end
bindkey -v "^R" history-incremental-pattern-search-backward
bindkey -v "^S" history-incremental-pattern-search-forward
# color
autoload -Uz colors; colors
[[ -f "$HOME/.dircolors" ]] && source "$HOME/.dircolors"
# completion
zmodload -i zsh/complist
autoload -U compinit && compinit -C
setopt \
complete_in_word \
glob_complete \
hist_expand \
no_beep \
numeric_glob_sort
zstyle ':completion:*' format '%F{magenta}-- %d --%f'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:options' description yes
zstyle ':completion:*:options' auto-description '%d'
zstyle ':completion:*:corrections' format ' %F{yellow}-- %d (errors: %e) --%f'
zstyle ':completion:*:descriptions' format ' %F{magenta}-- %d --%f'
zstyle ':completion:*:messages' format ' %F{blue}-- %d --%f'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*:default' list-colors "${(s.:.)LS_COLORS}"
# zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z} r:|[._-]=*'
# zstyle ':completion:*' completer _oldlist _complete _match _ignored _approximate _prefix
zstyle ':completion:sudo:*' environ PATH="$SUDO_PATH:$PATH"
zstyle ':completion:*:cd:*' tag-order local-directories path-directories
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion:*:*:*:*:processes' command 'ps -u $USER -o pid,user,comm -w'
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01'
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:*:kill:*' force-list always
zstyle ':completion:*:*:kill:*' insert-ids single
zstyle ':completion:*:manuals' separate-sections true
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect 'k' vi-up-line-or-history
# url-quote-magic
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
# expand childa to $HOME
expand-to-home-or-complete() { # {{{
if [ "$LBUFFER" = "" -o "$LBUFFER[-1]" = " " ]; then
LBUFFER+="~/"
else
zle self-insert
fi
} # }}}
zle -N expand-to-home-or-complete
bindkey -v "\\" expand-to-home-or-complete
# alias
alias :q=exit
alias l='gls --color=auto -AF'
alias ls='gls --color=auto -AF'
alias ll='gls --color=auto -AFl'
whence hub >/dev/null 2>&1 && alias git=hub
# prompt
setopt \
prompt_subst \
prompt_percent \
transient_rprompt
autoload -U promptinit && promptinit
__configure_prompt() {
local ok_yuno="%F{yellow}✘╹◡╹✘%f"
local bad_yuno="%F{red}✘>﹏<✘%f"
local command_line="%(?.${ok_yuno}.${bad_yuno}) < "
local git_is_dirty git_local_changes git_upstream_changes
if git rev-parse --is-inside-work-tree &>/dev/null; then
command git diff --no-ext-diff --quiet --exit-code || git_is_dirty='*'
local git_upstream_status=$(command git rev-list --left-right --count ...@{u} 2>/dev/null)
git_upstream_status=(${(ps:\t:)git_upstream_status})
local left=${git_upstream_status[1]} right=${git_upstream_status[2]}
(( ${left:-0} > 0 )) && git_local_changes='⇡'
(( ${right:-0} > 0 )) && git_upstream_changes='⇣'
fi
export PROMPT="${command_line}"
export RPROMPT="${git_is_dirty}${git_local_changes}${git_upstream_changes}[%~]"
}
autoload -Uz add-zsh-hooks
add-zsh-hook precmd __configure_prompt
# tmux
if whence tmux >/dev/null && [ -z "$TMUX" ]; then
if $(tmux has-session 2>/dev/null); then
tmux attach-session -t "${HOST%%.*}"
else
tmux new-session -s "${HOST%%.*}"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment