summary refs log tree commit diff
path: root/.zshrc
blob: be70cd7843a2e005fd210a79f5c5aaf07df395a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
unsetopt beep
setopt nomatch interactive_comments
setopt inc_append_history hist_ignore_dups
HISTFILE=~/.history HISTSIZE=5000 SAVEHIST=5000

autoload -Uz compinit && compinit
autoload -Uz colors && colors

bindkey -v
KEYTIMEOUT=1

OLDPATH=$PATH
path=(
  /sbin /bin
  /usr/local/sbin /usr/local/bin
  /usr/sbin /usr/bin
  ~/.bin ~/.cargo/bin ~/.gem/bin
)

export PAGER=less MANPAGER=less EDITOR=vim GIT_EDITOR=vim
type nvim > /dev/null \
  && MANPAGER=manpager EDITOR=nvim GIT_EDITOR=nvim \
  && alias vim=nvim
export GPG_TTY=$TTY

export CLICOLOR=1
[ "$OSTYPE" = 'linux-gnu' ] \
  && alias ls='ls --color=auto' grep='grep --color' rm='rm -I'

alias ga='git add'
alias gb='git branch'
alias gc='git commit'
alias gca='git commit --amend'
alias gco='git checkout'
alias gd='git diff'
alias gf='git fetch'
alias gl='git log --graph --pretty=log'
alias gm='git merge'
alias gmv='git mv'
alias gp='git push'
alias gr='git rebase'
alias gra='git rebase --abort'
alias grc='git rebase --continue'
alias grm='git rm'
alias grs='git rebase --skip'
alias gs='git status --short --branch'
alias gsh='git show'
alias gst='git stash'
alias gt='git tag'
alias gu='git pull'

setopt prompt_subst
_prompt_git() {
  local dotgit=.git head
  [ -d "$dotgit" ] || dotgit=../.git
  [ -d "$dotgit" ] || return 0
  read head < "$dotgit/HEAD"
  case "$head" in
    ref:*) echo ":${head#*/*/}";;
    *) echo ":${head:0:7}";;
  esac
}
[ -n "$SSH_CLIENT" ] && _prompt_ssh='%F{magenta}'
PROMPT="%(?.%F{green}$_prompt_ssh.%F{red})»%f "
RPROMPT='%F{blue}%50<…<%~%F{yellow}$(_prompt_git)%f'

_n() { _n() { echo } }
_title() { print -Pn "\e]0;$1\a" }
_title_precmd() { _title "%1~" }
_title_preexec() { _title "%1~: $1" }
precmd_functions=(_n _title_precmd)
preexec_functions=(_title_preexec)