/
zshrc
106 lines (80 loc) · 2.19 KB
/
zshrc
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
# General options {{{
HISTFILE=~/.zsh-histfile
HISTSIZE=1000
SAVEHIST=1000
unsetopt beep
bindkey -v
bindkey "^R" history-incremental-search-backward
export PATH=$PATH:/usr/local/sbin:$HOME/bin:/usr/local/heroku/bin
export LANG=en_US.UTF-8
export EDITOR=vim
zstyle :compinstall filename '/home/jose/.zshrc'
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
autoload -Uz compinit && compinit
autoload -Uz colors && colors
setopt PROMPT_SUBST
RPROMPT='%~%{$fg[yellow]%}$(git_branch)%{$reset_color%}$(git_status)'
PROMPT="%{$fg[yellow]%}▶ %{$reset_color%}"
TERM="screen-256color"
# }}}
### Functions {{{
function git_status() { # {{{
local st="$(git status 2> /dev/null)"
local ret=""
local color="green"
if [[ $st == *Untracked* ]] then
ret="${ret} @"
color="magenta"
fi
if [[ $st == *"not staged for commit"* ]] then
ret="${ret} ?"
color="red"
fi
if [[ $st == *"to be committed"* ]] then
ret="${ret} !"
color="yellow"
fi
if [[ $st == *clean* ]] then
ret="${ret} \u2713"
color="green"
fi
echo "%{$fg[$color]%}$ret%{$reset_color%}"
} # }}}
function git_branch() { # {{{
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
} # }}}
function cdp() {
cd $(find ~ -type d -maxdepth 6 -name .git 2>/dev/null | sed 's/.git//' | fzf )
}
# }}}
### Alias {{{
alias be="bundle exec"
alias g=git
alias hub=git-hub
alias ls='ls --color=auto'
alias r="bundle exec rails"
alias t=todo.sh
alias v=vim
alias e="emacs &; disown"
alias dc=docker-compose
alias d=docker
# }}}
# Source external applications {{{
source ~/.zshenv
source ~/.nvm/nvm.sh
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
test -s ~/.kiex/scripts/kiex && source ~/.kiex/scripts/kiex
test -s direnv && eval "$(direnv hook zsh)"
test -s ~/.config/shell/less_termcap.sh && source ~/.config/shell/less_termcap.sh
# }}}
# vim: foldmethod=marker foldmarker={{{,}}}
_direnv_hook() {
eval "$(direnv export zsh)";
}
typeset -ag precmd_functions;
if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then
precmd_functions+=_direnv_hook;
fi
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
alias dnfi="sudo dnf install -y"