forked from sorin-ionescu/prezto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
106 lines (86 loc) · 2.25 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
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Customize to your needs...
autoload bashcompinit && bashcompinit
autoload -Uz compinit && compinit
if command -v direnv > /dev/null 2>&1; then
eval "$(direnv hook zsh)"
fi
if command -v nodenv > /dev/null 2>&1; then
eval "$(nodenv init -)"
fi
if command -v rbenv > /dev/null 2>&1; then
eval "$(rbenv init -)"
fi
if command -v pyenv > /dev/null 2>&1; then
eval "$(pyenv init --path)"
fi
if command -v aws > /dev/null 2>&1; then
complete -C '/usr/local/bin/aws_completer' aws
fi
export PATH=$PATH:~/bin
if command -v go > /dev/null 2>&1; then
GOPATH=$(go env GOPATH)
export GOPATH=$GOPATH
export GO111MODULE="on"
fi
# ヒストリに追加されるコマンド行が古いものと同じなら古いものを削除
setopt hist_ignore_all_dups
# スペースで始まるコマンド行はヒストリリストから削除
setopt hist_ignore_space
# 余分な空白は詰めて記録
setopt hist_reduce_blanks
# historyコマンドは履歴に登録しない
setopt hist_no_store
# history
function peco-select-history() {
BUFFER=$(history -n 1 | tail -r | awk '!a[$0]++' | peco)
CURSOR=$#BUFFER
zle reset-prompt
}
zle -N peco-select-history
bindkey '^r' peco-select-history
function peco-src() {
local base=$(ghq root)
local src=$(ghq list | peco --query "$LBUFFER")
if [ -n "$src" ]; then
BUFFER="cd $base/$src"
zle accept-line
fi
zle -R -c
}
zle -N peco-src
bindkey '^]' peco-src
function paws {
local profile=$(perl -nle 'print $1 if /^[[](?:profile\s+)?([^]]+)/' ~/.aws/config | peco)
if [ -n "$profile" ]; then
AWS_PROFILE=$profile
export AWS_PROFILE
echo "AWS_PROFILE is now $AWS_PROFILE"
fi
}
function penv {
local env=$(echo "development\nstaging\nproduction" | peco)
if [ -n "$env" ]; then
APP_ENV=$env
export APP_ENV
echo "APP_ENV is now $APP_ENV"
fi
}
# Activate SSH Agent
if ! ssh-add -l > /dev/null 2>&1; then
ssh-add --apple-use-keychain
fi
# load local settings
LOCAL_FILE="${HOME}/.zshrc.local"
if [ -e $LOCAL_FILE ]; then
source $LOCAL_FILE
fi