-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc
More file actions
143 lines (121 loc) · 3.32 KB
/
dot_zshrc
File metadata and controls
143 lines (121 loc) · 3.32 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
# ----------------------------------------
# 基本設定
# ----------------------------------------
export LANG=ja_JP.UTF-8
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
# 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
)
# mise
eval "$(mise activate zsh)"
# direnv
eval "$(direnv hook zsh)"
# zoxide
export _ZO_DOCTOR=0
if command -v zoxide &>/dev/null; then
eval "$(zoxide init zsh)"
# z: 実パスなら cd、zoxide でヒットしなければ zi にフォールバック
unalias z 2>/dev/null
z() {
if [[ $# -eq 0 ]]; then
__zoxide_z
return
fi
if [[ -d "$*" ]]; then
builtin cd -- "$*"
return
fi
__zoxide_z "$@" 2>/dev/null || __zoxide_zi "$@"
}
fi
# sheldon plugin manager
eval "$(sheldon source)"
# gcloud sdk
if [ -d "$(brew --prefix)/Caskroom/google-cloud-sdk/" ] ; then
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
fi
# ----------------------------------------
# ツール設定
# ----------------------------------------
# fzf
export FZF_DEFAULT_OPTS='
--extended
--ansi
--multi
--border
--reverse
'
command -v fzf &>/dev/null && 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"
alias nosleep="sudo pmset -a disablesleep 1"
alias yessleep="sudo pmset -a disablesleep 0"
# ----------------------------------------
# カスタム関数
# ----------------------------------------
# ディレクトリ変更時の自動ls実行
function chpwd() {
ls
}
# 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で逆順に表示