-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
136 lines (116 loc) · 3.3 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
fpath=(~/.zsh/completion $fpath)
autoload -U compinit
compinit
setopt HIST_IGNORE_DUPS
autoload -U promptinit
promptinit
prompt redhat
autoload -U colors
colors
colornum() {
COLORNO="$(hostname|sum|cut -c1-2)"
# correct color looks like black ink
if [ "$COLORNO" = "10" ]; then
COLORNO="19"
fi
if [ "$COLORNO" = "e3" ]; then
COLORNO="e6"
fi
if [ "$COLORNO" = "e4" ]; then
COLORNO="e7"
fi
}
colornum
#local HOSTC=$'%{\e[38;5;'"$(printf "%d\n" 0x$(hostname|md5sum|cut -c1-2))"'m%}'
#local DEFAULTC=$'%{\e[m%}'
#local HOSTCOLOR=$'\e[38;5;'"$(printf "%d\n" 0x$(hostname|sum|cut -c1-2))"'m'
local HOSTCOLOR=$'\e[38;5;'"$(printf "%d\n" 0x$COLORNO)"'m'
#PROMPT="%{$fg[green]%}[%n@%m %1~]%#%{$reset_color%} "
PROMPT="%{$HOSTCOLOR%}[%n@%m %1~]%#%{$reset_color%} "
#LEFT_PROMPT="%{$fg[green]%}[%n@%m"
LEFT_PROMPT="%{$HOSTCOLOR%}[%n@%m"
RIGHT_PROMPT=" %1~]%#%{$reset_color%} "
HISTFILE=~/.history
HISTSIZE=1000
SAVEHIST=2000
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
# export PAGER=/usr/local/bin/lv
# export EDITOR=/usr/local/bin/emacsclient
export PATH=$PATH:/usr/local/opt/go/libexec/bin
export PATH="${HOME}/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
#nodejs by nodebrew
export PATH=$HOME/.nodebrew/current/bin:$PATH
# alias ls='ls --show-control-chars' # prepare for kanji as ???
_set_env_git_current_branch() {
GIT_CURRENT_BRANCH=$( git branch &> /dev/null | grep '^\*' | cut -b 3- )
}
_update_prompt () {
if [ "`git ls-files 2>/dev/null`" ]; then
PROMPT="%{$fg[green]%}${LEFT_PROMPT}:[${GIT_CURRENT_BRANCH}]${RIGHT_PROMPT}%{$reset_color%} "
fi
}
: <<'#__COMMENT_OUT__'
_update_rprompt () {
if [ "`git ls-files 2>/dev/null`" ]; then
RPROMPT="[%~:$GIT_CURRENT_BRANCH]"
else
RPROMPT="[%~]"
fi
}
#__COMMENT_OUT__
precmd()
{
_set_env_git_current_branch
_update_prompt
}
chpwd()
{
_set_env_git_current_branch
_update_prompt
}
# rbenv completions
if [[ ! -o interactive ]]; then
return
fi
compctl -K _rbenv rbenv
_rbenv() {
local words completions
read -cA words
if [ "${#words}" -eq 2 ]; then
completions="$(rbenv commands)"
else
completions="$(rbenv completions ${words[2,-2]})"
fi
reply=("${(ps:\n:)completions}")
}
# https://github.com/direnv/direnv
eval "$(direnv hook zsh)"
case ${OSTYPE} in
darwin*)
bindkey '' forward-word
bindkey '' backward-word
# Brew-file
if [ -f $(brew --prefix)/etc/brew-wrap ]; then
source $(brew --prefix)/etc/brew-wrap
fi
export LDFLAGS="-L/usr/local/opt/[email protected]/lib -L/usr/local/opt/imagemagick@6/lib -L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include -I/usr/local/opt/imagemagick@6/include -I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
export HOMEBREW_GITHUB_API_TOKEN=""
export BUNDLE_GITHUB__COM="github_user:"
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc'
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc'
;;
linux*)
;;
esac
# peco
function peco-history-selection() {
BUFFER=`history -n 1 | tail -r | awk '!a[$0]++' | peco`
CURSOR=$#BUFFER
zle reset-prompt
}
zle -N peco-history-selection
bindkey '^R' peco-history-selection