-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.zshrc
195 lines (171 loc) · 4.38 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
autoload -Uz compinit
autoload -Uz promptinit
autoload -Uz vcs_info
compinit
promptinit
# history
HISTFILE=$HOME/.zsh-history
HISTSIZE=1000000
SAVEHIST=1000000
setopt EXTENDED_HISTORY
setopt SHARE_HISTORY
setopt BANG_HIST
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY
function history-all { history -E 1 }
REPORTTIME=3
export CDPATH=.:$HOME
setopt AUTO_CD
setopt AUTO_PUSHD
setopt PUSHD_IGNORE_DUPS
WORDCHARS='*?-.[]~&;!#$%^(){}<>'
# prompt
if [ -f ~/.zsh/my_prompt.zsh ]; then
source ~/.zsh/my_prompt.zsh
fi
# completion
zstyle ':completion:*:default' menu select
setopt list_packed
# C-S, C-Q によるフロー制御を使わない
setopt NO_FLOW_CONTROL
bindkey "^F" forward-word
bindkey "^B" backward-word
alias "$"=""
alias -g RD='RAILS_ENV=development'
alias -g RT='RAILS_ENV=test'
alias -g RP='RAILS_ENV=production'
alias -g CSU='| cut -d":" -f1 | sort | uniq'
alias -g SUS='| sort | uniq -c | sort -nr'
alias -g V=' 2>&1 | vim -'
alias rm="gomi"
alias a="git add"
alias b="bat --style=plain"
alias c="ctop"
alias f="git fetch -p"
alias g="git"
alias t="tig"
alias h="hivemind"
alias s="git status -sb"
alias r="bundle exec rails"
alias ru="bundle exec rackup"
# alias m="bundle exec middleman"
alias m="git switch -d remotes/origin/HEAD"
alias rake="noglob bundle exec rake"
alias rspec="bundle exec rspec"
alias :q="exit"
alias bi="bundle config set path ~/.bundle && bundle install --jobs=4"
alias cod="git checkout develop"
alias com="git checkout master"
alias cow="git checkout working"
alias cop="bundle exec rubocop"
alias my="mycli -u root"
alias tree="eza --tree -F"
alias d="docker"
alias dc="docker compose"
alias cdr="cd \`git rev-parse --show-toplevel\`"
alias sort="LC_COLLATE=C sort"
function v() {vi -p ${${=*/:/ +}/:*}}
case "${OSTYPE}" in
darwin*)
alias l='ls -lFG'
alias lsd='ls -lFG | grep -e "^d" --color=never'
;;
linux*)
alias l='ls -lvF --color'
alias lsd='ls -lvF --color | grep -e "^d" --color=never'
;;
esac
# cd したら ls
function chpwd() {
case "${OSTYPE}" in
darwin*)
ls -lF -G
;;
linux*)
ls -lvF --color
;;
esac
}
# enter したら git status
# http://qiita.com/yuyuchu3333/items/e9af05670c95e2cc5b4d
function do_enter() {
if [ -n "$BUFFER" ]; then
zle .reset-prompt # PROMPT を実行時のタイプスタンプにするため
zle .accept-line
return 0
fi
if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = 'true' ]; then
echo
git status -sb
echo
fi
zle .reset-prompt
return 0
}
zle -N do_enter
bindkey '^m' do_enter
# homebrew
eval $(/opt/homebrew/bin/brew shellenv)
export HOMEBREW_NO_ENV_HINTS=1
# plenv
if which plenv > /dev/null; then
eval "$(plenv init - zsh)"
fi
# chruby
source /opt/homebrew/share/chruby/chruby.sh
chruby ruby-dev
# ruby
export DISABLE_SPRING=1
export DISABLE_DATABASE_ENVIRONMENT_CHECK=1
# go
export GOPATH=$(go env GOPATH)
export PATH=$PATH:$GOPATH/bin
export GO111MODULE=on
# fzf
if [ -f ~/.zsh/my_fzf.zsh ]; then
source ~/.zsh/my_fzf.zsh
fi
# http://ukstudio.jp/2015/03/26/open_pull_request/
function find-pr() {
local parent=$2||'master'
git log $1..$2 --merges --ancestry-path --reverse --oneline | head -n1
}
function find-pr-open() {
local pr="$(find-pr $1 $2 | awk '{print substr($5, 2)}')"
local repo="$(git config --get remote.origin.url | sed 's#ssh://git@#https://#' | sed 's/\.git$//')"
open "${repo}/pull/${pr}"
}
function find-mr-open() {
local pr="$(find-pr $1 $2 | awk '{print substr($7, 2)}')"
local repo="$(git config --get remote.origin.url | sed 's#ssh://git@#http://#' | sed 's/\.git$//')"
open "${repo}/merge_requests/${pr}"
}
function rm_xattr() {
for file in $*
do
for attr in $(xattr $file)
do
xattr -d $attr $file
done
done
}
# http://blog.kamipo.net/entry/2013/02/20/122225
function www() {
if type ruby > /dev/null; then
ruby -run -e httpd -- --port=5000 .
elif type python > /dev/null; then
if python -V 2>&1 | grep -qm1 'Python 3\.'; then
python -m http.server 5000
else
python -m SimpleHTTPServer 5000
fi
elif type node > /dev/null; then
node -e "var c=require('connect'), d=process.env.PWD; c().use(c.logger()).use(c.static(d)).use(c.directory(d)).listen(5000);"
elif type php > /dev/null && php -v | grep -qm1 'PHP 5\.[45]\.'; then
php -S 0.0.0.0:5000
fi
}
# local
if [ -f ~/.zsh/local.zsh ]; then
source ~/.zsh/local.zsh
fi