-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshenv
176 lines (157 loc) · 4.64 KB
/
.zshenv
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
#################################################
# zplug
#################################################
source $HOME/.zplug/init.zsh
zplug 'zsh-users/zsh-completions'
zplug 'zsh-users/zsh-syntax-highlighting', defer:2
zplug 'zsh-users/zsh-autosuggestions'
#Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
# Then, source plugins and add commands to $PATH
zplug load
#################################################
# Options
#################################################
autoload -Uz colors && colors
autoload -Uz compinit && compinit
autoload -Uz bashcompinit && bashcompinit
# 補完候補がない場合にビープ音を鳴らさない
setopt no_beep
# シェルのプロセス間で履歴を共有
setopt share_history
# 重複したヒストリは追加しない
setopt hist_ignore_all_dups
# 複数のzshを使うときにhistoryファイルに上書きせずに追加
setopt append_history
# cdしたらpushd
setopt auto_pushd
# 補完候補が複数ある時に,一覧表示
setopt auto_list
# 補完候補が複数ある時に自動的に一覧表示
setopt auto_menu
# コマンドをtypoした時に聞き直してくれる
setopt correct
# =の後のパスとかも補完
setopt magic_equal_subst
# カッコの対応を自動で補完
setopt auto_param_keys
# For M1 Mac
typeset -U path PATH
export ARCH=`uname -m`
path=(
/opt/homebrew/bin(N-/)
/usr/local/bin(N-/)
$path
)
if [[ "${(L)$( uname -s )}" == darwin ]] && (( $+commands[arch] )); then
alias brew="arch -arch x86_64 /usr/local/bin/brew"
alias x64='exec arch -arch x86_64 "$SHELL"'
alias a64='exec arch -arch arm64e "$SHELL"'
switch-arch() {
if [[ "$(uname -m)" == arm64 ]]; then
x64
elif [[ "$(uname -m)" == x86_64 ]]; then
a64
fi
exec arch -arch $arch "$SHELL"
}
fi
setopt magic_equal_subst
#################################################
# Styles
#################################################
# 大文字入力をした時以外は大文字小文字を区別しないで補完する
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}'
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=244"
#################################################
# ENVs
#################################################
export XDG_CONFIG_HOME=$HOME/.config
export LANG=ja_JP.UTF-8
export LESSCHARSET=utf-8
export PATH=$HOME/.cargo/bin:$PATH
export PATH=$HOME/go/bin:$PATH
export PATH=$HOME/tools/flutter/bin:$PATH
export PATH=/usr/local/Cellar/[email protected]/9.6.21/bin:$PATH
export PATH=/usr/local/opt/openjdk/bin:$PATH
export PATH=/usr/local/opt/mysql-client/bin:$PATH
export PATH=$PATH:/Users/ryutaro.matsumoto/Library/Android/sdk/platform-tools
export PATH=/usr/local/opt/openjdk/bin:$PATH
#export PATH=$HOME/go/bin:$PATH
#export PATH=$HOME/tools/flutter/bin:$PATH
export PYENV_ROOT="$HOME/.pyenv"
export RUST_BACKTRACE=1
export CPPFLAGS="-I/usr/local/opt/openjdk/include"
#################################################
# Complete
#################################################
complete -C '/usr/local/bin/aws_completer' aws
#################################################
# Functions
#################################################
function cdls()
{
\cd "$@" && lsd -a
}
function copy()
{
\cat "$@" | pbcopy
}
function staas()
{
cluster=$1
case ${cluster} in
jpe2b) endpoint="https://jpe2b-1000-staas.r-local.net/" ;;
euc1a) endpoint="https://euc1a-1000-staas.r-local.net/" ;;
usw1a) endpoint="https://usw1a-1000-staas.r-local.net/" ;;
*)
echo "Invalid cluster"
return 1
;;
esac
aws --endpoint-url ${endpoint} s3 ${@:2}
}
#################################################
# Command alternation
#################################################
alias vi="nvim"
alias vim="nvim"
alias cat="bat"
alias ls="lsd"
alias find="fd"
alias grep="rg"
alias ps="procs"
alias top="ytop"
alias hex="hexyl"
alias cd="cdls"
#################################################
# Useful aliases
#################################################
alias ss="source ~/.zshenv"
alias l="ls -l"
alias l1="ls -1"
alias la="ls -a"
alias lla="ls -la"
alias lt="ls --tree"
alias cdw="cd ~/work"
alias cdd="cd ~/dotfiles/"
alias cdn="cd ~/dotfiles/.config/nvim"
alias ga="git add "
alias ga.="git add ."
alias gb="git branch"
alias gc="git commit"
alias gcm="git commit -m "
alias gmend="git commit --amend"
alias gs="git status"
alias gd="git diff"
alias gp="git push "
alias gsw="git switch"
alias dc="docker compose"
alias sudo="sudo -E "
alias k="kubectl"
. "$HOME/.cargo/env"