-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.zshrc
More file actions
164 lines (134 loc) · 3.69 KB
/
.zshrc
File metadata and controls
164 lines (134 loc) · 3.69 KB
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
bindkey -e
# Load Plugins
source ~/.zsh/antigenrc
setopt ignore_eof
setopt interactive_comments
setopt no_beep
# cd関連
setopt autocd
setopt auto_pushd
setopt pushd_ignore_dups
alias b='cd ..'
# 補完関連
unsetopt auto_menu
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit -u
if command -v aws_completer >/dev/null 2>&1; then
autoload bashcompinit && bashcompinit
complete -C '/usr/bin/aws_completer' aws
fi
# Environment variables
source ~/.zsh/credentials
export TZ=Asia/Tokyo
export LANG=ja_JP.utf8
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
export LESS='-R -i -X'
export PATH=$HOME/bin:$PATH
# Append PATH to node
export NODE_PATH=/opt/node
export PATH=$PATH:$NODE_PATH/bin
# Aliases
alias irb='pry'
alias crontab='crontab -i'
alias less='less -N'
alias ls='ls --color=auto'
alias la='ls -la'
alias ll='ls -l'
alias diff='git diff --no-index'
alias grep='grep --color=auto'
alias tailf='tail -f'
alias fd='fd --hidden --no-ignore --glob'
# Use PATH for root user when sudo without password
if sudo -n true 2>/dev/null; then
ROOT_PATH=$(sudo -n sh -c 'echo $PATH' 2>/dev/null)
else
ROOT_PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
fi
alias sudo="sudo env PATH=${ROOT_PATH}:/opt/nvim/bin "
if command -v bat >/dev/null 2>&1; then
alias cat='bat'
alias less='bat'
fi
if command -v aicommits >/dev/null 2>&1; then
alias aic='aicommits --generate 3'
fi
# show filelist when change directory.
chpwd() {
ls -l
}
# <C-s>/<C-q>による画面更新の停止機能を無効化
stty stop undef
stty start undef
# history settings
export HISTFILE=~/.histfile
export HISTSIZE=1000000
export SAVEHIST=1000000
setopt hist_ignore_dups
setopt share_history
setopt hist_no_store
setopt hist_expand
# 入力中の内容にマッチする物のみ履歴をたどる
autoload -Uz 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
# pecoを使った各種検索を追加
if command -v peco >/dev/null 2>&1; then
source ~/.zsh/peco.sh
fi
# 空Enterでgit status表示
function do_enter() {
if [ -n "$BUFFER" ]; then
zle accept-line
return 0
fi
echo
# ls
# ↓おすすめ
# ls_abbrev
if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = 'true' ]; then
echo
git status -sb
fi
zle reset-prompt
return 0
}
zle -N do_enter
bindkey '^m' do_enter
# promptにgitのbranchとstatusを表示
GIT_PS1_SHOWCOLORHINTS=true
GIT_PS1_SHOWUPSTREAM=verbose
source ~/.zsh/git-prompt.sh
setopt PROMPT_SUBST ; PS1='[%n@%M]%~$(__git_ps1 " (%s)")%% '
# Use pyenv
if [ -f "$PYENV_ROOT/bin/pyenv" ]; then
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
# Add alias for python3
python --version 2>&1 | grep "Python 2" > /dev/null
if [ $? -eq 0 ]; then
alias python=python3
fi
# NeoVim
alias vi='nvim'
alias vim='nvim'
alias view='nvim -R'
export PATH=/opt/nvim/bin:$PATH
# Change window title
echo -e "\033];$(whoami)@$(hostname)\007"
# Save raw cmdline for tmux-resurrect
if [[ -n "$TMUX_PLUGIN_MANAGER_PATH" ]]; then
source $TMUX_PLUGIN_MANAGER_PATH/tmux-resurrect/scripts/helpers.sh
mkdir -p "$(resurrect_dir)"
touch $(resurrect_dir)/tmux_resurrect_cmdline
# Clear cmdline which was generated by old process id when reuse it
sed -i "/^$$:/d" $(resurrect_dir)/tmux_resurrect_cmdline
function save_raw_cmdline_for_tmux_resurrect() {
sed -i "/^$$:/d" $(resurrect_dir)/tmux_resurrect_cmdline
echo "$$:$1" >> $(resurrect_dir)/tmux_resurrect_cmdline
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec save_raw_cmdline_for_tmux_resurrect
fi