blob: 551033daadc753fe3ea024046cb32cf8ed7176fa (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# Save 5000 lines of history, writing after each command, ignoring duplicates.
HISTFILE=~/.history
HISTSIZE=SAVEHIST=5000
setopt inc_append_history hist_ignore_dups
# Error if glob does not match.
setopt nomatch
# Allow comments in interactive shell.
setopt interactive_comments
# No.
unsetopt beep
# Vim line editing.
bindkey -v
# Initialize completion.
autoload -Uz compinit && compinit
# Prompt with single character on the left, normally green, magenta over SSH,
# red after a failed command. Directory and git branch on the right.
setopt prompt_subst
autoload colors && colors
[[ -n "$SSH_CLIENT" ]] && _prompt_ssh_color="$fg[magenta]"
_prompt_git_branch() {
[[ -f .git/HEAD ]] || return 0
local head
read head < .git/HEAD
case "$head" in
ref:*)
echo ":${head#*/*/}"
;;
*)
echo ":${head:0:7}"
;;
esac
}
PROMPT='%{%(?.$fg[green]$_prompt_ssh_color.$fg[red])%}»%{$reset_color%} '
RPROMPT='%{$fg[blue]%}%-50<…<%~%{$fg[yellow]%}$(_prompt_git_branch)%{$reset_color%}'
# Set title to directory name at prompt, prefixed with hostname over SSH. Add
# current command to title while running.
_title() {
[[ "$TERM" =~ 'xterm' ]] && print -Pn "\e]0;$@\a"
}
[[ -n "$SSH_CLIENT" ]] && _title_host='%m:'
_title_preexec() { _title "$_title_host%1~: $1" }
_title_precmd() { _title "$_title_host%1~" }
typeset -ga preexec_functions
typeset -ga precmd_functions
preexec_functions+=_title_preexec
precmd_functions+=_title_precmd
# General environment setup.
PATH=$PATH:~/.bin
export EDITOR=vim
export CLICOLOR=1 # color ls output on OS X
# Detect OS X for conditional aliases.
[[ "$OSTYPE" =~ 'darwin' ]] && alias osx=true || alias osx=false
# Color output on Linux.
osx || alias ls='ls --color'
osx || alias grep='grep --color'
# Verbose output from rm with confirmation on Linux.
osx || alias rm='rm -vI'
osx && alias rm='rm -v'
# Suppress output from Linux gvim, alias gvim to MacVim.
osx || alias gvim='gvim 2> /dev/null'
osx && alias gvim=mvim
alias g=git
alias ga='git add'
alias gb='git branch'
alias gc='git commit'
alias gca='git commit --amend'
alias gcl='git clone'
alias gco='git checkout'
alias gd='git diff'
alias gi='git init'
alias gl='git log'
alias glg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --color"
alias gm='git merge'
alias gmv='git mv'
alias gp='git push'
alias gr='git rebase'
alias grc='git rebase --continue'
alias grs='git rebase --skip'
alias gra='git rebase --abort'
alias grm='git rm'
alias gs='git status -sb'
alias gsh='git show'
alias gst='git stash'
alias gt='git tag'
alias gu='git pull'
alias gf='git fetch'
alias gbl='git blame'
alias hu=heroku
[[ -f ~/.nvm/nvm.sh ]] && source ~/.nvm/nvm.sh
# Prevent red first prompt.
true
|