-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
198 lines (172 loc) · 7.55 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
196
197
198
# Created by kohey
# (d) is default on
# ------------------------------
# General Settings
# ------------------------------
export EDITOR=emacs # エディタをemacsに設定
export LANG=ja_JP.UTF-8 # 文字コードをUTF-8に設定
export KCODE=u # KCODEにUTF-8を設定
export AUTOFEATURE=true # autotestでfeatureを動かす
bindkey -e # キーバインドをemacsモードに設定
#bindkey -v # キーバインドをviモードに設定
setopt no_beep # ビープ音を鳴らさないようにする
setopt auto_cd # ディレクトリ名の入力のみで移動する
setopt auto_pushd # cd時にディレクトリスタックにpushdする
setopt correct # コマンドのスペルを訂正する
setopt magic_equal_subst # =以降も補完する(--prefix=/usrなど)
setopt prompt_subst # プロンプト定義内で変数置換やコマンド置換を扱う
setopt notify # バックグラウンドジョブの状態変化を即時報告する
setopt equals # =commandを`which command`と同じ処理にする
### Complement ###
autoload -U compinit; compinit # 補完機能を有効にする
setopt auto_list # 補完候補を一覧で表示する(d)
setopt auto_menu # 補完キー連打で補完候補を順に表示する(d)
setopt list_packed # 補完候補をできるだけ詰めて表示する
setopt list_types # 補完候補にファイルの種類も表示する
bindkey "^[[Z" reverse-menu-complete # Shift-Tabで補完候補を逆順する("\e[Z"でも動作する)
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # 補完時に大文字小文字を区別しない
### Glob ###
setopt extended_glob # グロブ機能を拡張する
unsetopt caseglob # ファイルグロブで大文字小文字を区別しない
### History ###
HISTFILE=~/.zsh_history # ヒストリを保存するファイル
HISTSIZE=10000 # メモリに保存されるヒストリの件数
SAVEHIST=10000 # 保存されるヒストリの件数setopt bang_hist # !を使ったヒストリ展開を行う(d)
setopt extended_history # ヒストリに実行時間も保存する
setopt hist_ignore_dups # 直前と同じコマンドはヒストリに追加しない
setopt share_history # 他のシェルのヒストリをリアルタイムで共有する
setopt hist_reduce_blanks # 余分なスペースを削除してヒストリに保存する
# マッチしたコマンドのヒストリを表示できるようにする
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^P" history-beginning-search-backward-end
bindkey "^N" history-beginning-search-forward-end
#boot2docker
# すべてのヒストリを表示する
function history-all { history -E 1 }
# ------------------------------
# Look And Feel Settings# ------------------------------
### Ls Color ###
# 色の設定
export LSCOLORS=Exfxcxdxbxegedabagacad
# 補完時の色の設定
export LS_COLORS='di=01;34:ln=01;35:so=01;32:ex=01;31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
# ZLS_COLORSとは?
export ZLS_COLORS=$LS_COLORS #lsコマンド時、自動で色がつく(ls -Gのようなもの?)
export CLICOLOR=true #補完候補に色を付ける
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
### Prompt ###
# プロンプトに色を付ける
autoload -U colors; colors
#一般ユーザ時
tmp_prompt="%{${fg[cyan]}%}%n%# %{${reset_color}%}"
tmp_prompt2="%{${fg[cyan]}%}%_> %{${reset_color}%}"
tmp_rprompt="%{${fg[green]}%}[%~]%{${reset_color}%}"
tmp_sprompt="%{${fg[yellow]}%}%r is correct? [Yes, No, Abort, Edit]:%{${reset_color}%}"
# rootユーザ時(太字にし、アンダーバーをつける)
if [ ${UID} -eq 0 ]; then
tmp_prompt="%B%U${tmp_prompt}%u%b"
tmp_prompt2="%B%U${tmp_prompt2}%u%b"
tmp_rprompt="%B%U${tmp_rprompt}%u%b"
tmp_sprompt="%B%U${tmp_sprompt}%u%b"
fi
PROMPT=$tmp_prompt # 通常のプロンプト
PROMPT2=$tmp_prompt2 # セカンダリのプロンプト(コマンドが2行以上の時に表示される)
RPROMPT=$tmp_rprompt # 右側のプロンプト
SPROMPT=$tmp_sprompt # スペル訂正用プロンプト
# SSHログイン時のプロンプト
[ -n "${REMOTEHOST}${SSH_CONNECTION}" ] &&
PROMPT="%{${fg[white]}%}${HOST%%.*} ${PROMPT}"
;
### Title (user@hostname) ###
precmd() {
echo -ne "\033]0;${USER}@${HOST%%.*}\007"
}
# ------------------------------
# Other Settings# ------------------------------
### Macports ###
case "${OSTYPE}" in darwin*)
export PATH=/usr/local/bin:/opt/local/lib/php:$PATH export MANPATH=/opt/local/share/man:/opt/local/man:$MANPATH ;;
esac
### Aliases ###
alias r=rails
alias v=vim
alias be='bundle exec'
alias e='emacs'
alias emacs='emacsclient -nw -a ""'
alias e_kill='emacsclient -e "(kill-emacs)"'
alias ll='ls -al'
alias s='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'
#bank_info
alias ds='echo -e "【昨日したこと】\\n【今日すること】\\n【課題感】\\n【ひとこと】\\n" | pbcopy'
alias pr_format='echo -e "## 概要 \\n## 関連URL \\n## 技術・UI変更点 \\n## 完了の定義 \\n## 未完了タスク \\n## 備考 \\n## 今回保留した項目とTODOリスト \\n## レビュアー \\n" | pbcopy'
# cdコマンド実行後、lsを実行する
function cd() {
builtin cd $@ && ls -al;
}
autoload -U colors; colors
function rprompt-git-current-branch {
local name st colors
if [[ "$PWD" =~ '/\.git(/.*)?$' ]]; then
return
fi
name=$(basename "`git symbolic-ref HEAD 2> /dev/null`")
if [[ -z $name ]]; then
return
fi
st=`git status 2> /dev/null`
if [[ -n `echo "$st" | grep "^nothing to"` ]]; then
color=${fg[green]}
elif [[ -n `echo "$st" | grep "^nothing added"` ]]; then
color=${fg[yellow]}
elif [[ -n `echo "$st" | grep "^# Untracked"` ]]; then
color=${fg_bold[red]}
else
color=${fg[red]}
fi
# %{...%} は囲まれた文字列がエスケープシーケンスであることを明示する
# これをしないと右プロンプトの位置がずれる
echo "%{$color%}$name%{$reset_color%} "
}
function peco-select-history() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(\history -n 1 | \
eval $tac | \
peco --query "$LBUFFER")
CURSOR=$#BUFFER
zle clear-screen
}
zle -N peco-select-history
bindkey '^r' peco-select-history
function pskill () {
ps aux | peco | awk '{print $2}' | xargs sudo kill -9
}
# プロンプトが表示されるたびにプロンプト文字列を評価、置換する
setopt prompt_subst
RPROMPT='[`rprompt-git-current-branch`%~]'
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export GOPATH=${HOME}/.golang
export PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin
export PATH="/usr/local/sbin:$PATH"
export PATH="/usr/local/bin:$PATH"
eval "$(direnv hook zsh)" # zsh の場合
# rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
# nodebrew
export PATH=$HOME/.nodebrew/current/bin:$PATH
# ghc
alias ghc='stack ghc --'
alias ghci='stack ghci --'
alias runhaskell='stack runhaskell --'
# read secert setting
source "${HOME}/.secret_zsh_setting"
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"