-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc
134 lines (110 loc) · 3.03 KB
/
dot_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
# ----------------------------------------
# 基本設定
# ----------------------------------------
export LANG=ja_JP.UTF-8
export EDITOR=vim
typeset -U path
export EDITOR="code --wait"
# コマンド履歴の設定
HISTFILE=${HOME}/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
# 履歴の共有と重複の制御
setopt share_history
setopt hist_ignore_dups
setopt hist_verify
# ディレクトリ操作の簡略化
setopt auto_cd
setopt auto_pushd
# コマンド補完機能の有効化
autoload -Uz compinit && compinit
# prompt
autoload -U promptinit; promptinit
prompt pure
# ----------------------------------------
# PATH設定
# ----------------------------------------
# Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
path=( \
${HOMEBREW_PREFIX}/opt/*/libexec/gnubin(N-/) \
${HOME}/.local/bin \
$path
)
manpath=( \
${HOMEBREW_PREFIX}/opt/*/libexec/gnuman(N-/) \
$manpath
)
# Python (pyenv)
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# direnv
eval "$(direnv hook zsh)"
# zoxide
eval "$(zoxide init zsh)"
# sheldon plugin manager
eval "$(sheldon source)"
# volta
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
# mise
export PATH="$HOME/.local/share/mise/shims:$PATH"
eval "$(mise activate zsh)"
# ----------------------------------------
# ツール設定
# ----------------------------------------
# fzf
export FZF_DEFAULT_OPTS='
--extended
--ansi
--multi
--border
--reverse
'
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# ----------------------------------------
# エイリアス
# ----------------------------------------
alias ls="ls --color=auto"
alias ll="ls -la"
alias python="python3"
alias pip="pip3"
alias g='ghq-cd'
alias rm='trash'
alias cat='bat'
alias cd='z'
alias clean_branch="git branch --merged | egrep -v \"(^\*|main|master)\" | xargs git branch -d"
alias brewup="brew update && brew upgrade && brew autoremove && brew cleanup -s"
# ----------------------------------------
# カスタム関数
# ----------------------------------------
# ディレクトリ変更時の自動ls実行とiTerm2のタブ名変更
function chpwd() {
ls
echo -ne "\033]0;$(pwd | rev | awk -F \/ '{print "/"$1"/"$2}'| rev)\007"
}
# ghqとfzfを使用したリポジトリ移動
function ghq-cd() {
local repository=$(ghq list | fzf +m)
[[ -n $repository ]] && cd $(ghq root)/$repository
}
# fzfを使用したhistory検索と実行
function hf() {
print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed -E 's/ *[0-9]*\*? *//' | sed -E 's/\\/\\\\/g')
}
# 入力補完
setopt auto_menu
setopt menu_complete
# 補完候補をカーソルで選択可能にする
zstyle ':completion:*:default' menu select=2
# 補完関数の遅延ロード
autoload -Uz compinit
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
compinit
else
compinit -C
fi
# キーバインディングの設定
bindkey "^I" menu-complete # タブキーで補完候補を順に表示
bindkey "^[[Z" reverse-menu-complete # Shift+Tabで逆順に表示