-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
171 lines (137 loc) · 4.42 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
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export SHELL=$(which zsh)
if [[ $(uname) == "Darwin" ]]
then
# If you come from bash you might have to change your $PATH.
export PATH=/usr/local/bin:/opt/homebrew/bin:$PATH
# use gnu core commands with their normal names
export PATH=$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/${USER}/opt/google-cloud-sdk/path.zsh.inc' ]
then
. '/Users/${USER}/opt/google-cloud-sdk/path.zsh.inc'
fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/${USER}/opt/google-cloud-sdk/completion.zsh.inc' ]
then
. '/Users/${USER}/opt/google-cloud-sdk/completion.zsh.inc'
fi
fi
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
plugins=(
aliases
fzf
git
zsh-autosuggestions
web-search
copyfile
dirhistory
history
jsontools
z
kubectl
you-should-use
# plugins for macos:
macos
)
source $ZSH/oh-my-zsh.sh
export FZF_DEFAULT_OPTS="--multi \
--height=50% \
--margin=1%,1%,1%,1% \
--layout=reverse-list \
--border=rounded \
--info=inline \
--prompt='$>' \
--pointer='→' \
--marker='♡' \
--header='CTRL-c or ESC to quit' \
--color='dark,fg:magenta'"
export FZF_CTRL_T_COMMAND='find . -type f -not -path "*/\.git/*"'
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# user defined aliases
# alias ls='ls --color'
alias ls='exa';
alias nv='nvim'
alias gch='git checkout'
alias kustomize='kubectl kustomize'
alias kct='kubectl ctx'
alias kns='kubectl ns'
alias lg='lazygit'
alias bat='bat --theme="base16"'
go() {
if [ $1 = "doc" ]; then
shift
command go doc $@ | bat -l go --style=plain
else
command go "$@"
fi
}
# Local bin setup
export PATH=$HOME/.local/bin:$PATH
# Go setup
export PATH=/usr/local/go/bin:$PATH
export PATH=$HOME/go/bin:$PATH
# Rust setup
export PATH=$HOME/.cargo/bin:$PATH
# kubectl shortcuts
source $HOME/.zsh/kubectl_alias.sh
export PATH=/usr/local/nvim/bin/:$PATH
export EDITOR=nvim
# krew
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
# fzf git branch checkout
#
fzf-git-branch() {
git rev-parse HEAD > /dev/null 2>&1 || return
git branch --color=always --all --sort=-committerdate |
grep -v HEAD |
fzf --height 50% --ansi --no-multi --preview-window right:65% \
--preview 'git log -n 50 --color=always --date=short --pretty="format:%C(auto)%cd %h%d %s" $(sed "s/.* //" <<< {})' |
sed "s/.* //"
}
fzf-git-checkout() {
git rev-parse HEAD > /dev/null 2>&1 || return
local branch
branch=$(fzf-git-branch)
if [[ "$branch" = "" ]]; then
echo "No branch selected."
return
fi
# If branch name starts with 'remotes/' then it is a remote branch. By
# using --track and a remote branch name, it is the same as:
# git checkout -b branchName --track origin/branchName
if [[ "$branch" = 'remotes/'* ]]; then
git checkout --track $branch
else
git checkout $branch;
fi
}
alias gco='fzf-git-checkout'
autoload -U compinit && compinit
# export OPENAI_API_KEY="$(cat $HOME/.secrets/openai)"
# nvm setup
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# pyenv setup for non debian dist
# eval "$(pyenv init --path)"
# tad auto completion
# source <(TAD_OFFLINE=1 tad zsh-completion)
# pyenv setup for debian dist
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
source ~/powerlevel10k/powerlevel10k.zsh-theme
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh