-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
205 lines (156 loc) · 5.98 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
###########################################################
# homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
###########################################################
# flags
export PATH="$(brew --prefix gettext)/bin:$PATH"
export CPPFLAGS="-I$(brew --prefix gettext)/include $CPPFLAGS"
export LDFLAGS="-L$(brew --prefix gettext)/lib $LDFLAGS"
export PATH="$(brew --prefix curl)/bin:$PATH"
export CPPFLAGS="-I$(brew --prefix curl)/include $CPPFLAGS"
export LDFLAGS="-L$(brew --prefix curl)/lib $LDFLAGS"
export PATH="$(brew --prefix openssl)/bin:$PATH"
export CPPFLAGS="-I$(brew --prefix openssl)/include $CPPFLAGS"
export LDFLAGS="-L$(brew --prefix openssl)/lib $LDFLAGS"
export CPPFLAGS="-I$(brew --prefix readline)/include $CPPFLAGS"
export LDFLAGS="-L$(brew --prefix readline)/lib $LDFLAGS"
export PATH="$(brew --prefix sqlite)/bin:$PATH"
export CPPFLAGS="-I$(brew --prefix sqlite)/include $CPPFLAGS"
export LDFLAGS="-L$(brew --prefix sqlite)/lib $LDFLAGS"
export PATH="$(brew --prefix ncurses)/bin:$PATH"
export CPPFLAGS="-I$(brew --prefix ncurses)/include $CPPFLAGS"
export LDFLAGS="-L$(brew --prefix ncurses)/lib $LDFLAGS"
export PATH="$(brew --prefix ruby)/bin:$(ruby -e 'puts Gem.bindir'):$PATH"
export CPPFLAGS="-I$(brew --prefix ruby)/include $CPPFLAGS"
export LDFLAGS="-L$(brew --prefix ruby)/lib $LDFLAGS"
###########################################################
# python
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
###########################################################
# go
export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$PATH"
###########################################################
# rust
source "$HOME/.cargo/env"
###########################################################
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" # This loads nvm bash_completion
###########################################################
# Pre configuration
# Define the environment variable ZPLUG_HOME
export ZPLUG_HOME="/opt/homebrew/opt/zplug"
# Loads zplug
source $ZPLUG_HOME/init.zsh
# Clear packages
zplug clear
# Load fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
###########################################################
# Packages
autoload -Uz compinit
compinit
zplug "wfxr/forgit", from:github
zplug "peterhurford/up.zsh", defer:2, from:github
zplug "tysonwolker/iterm-tab-colors", defer:2, from:github
zplug "zsh-users/zsh-autosuggestions", defer:2, from:github
zplug "zsh-users/zsh-completions", defer:2, from:github
zplug "zsh-users/zsh-syntax-highlighting", defer:2, from:github
###########################################################
# Install packages that have not been installed yet
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
else
echo
fi
fi
zplug load
###########################################################
# Post configuration
# Added by serverless binary installer
export PATH="$HOME/.serverless/bin:$PATH"
# iTerm
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# ###########################################################
# # Aliases
alias l="exa -lbF"
alias ll="exa -lbhHigUmuSa@ --sort=modified"
alias lt="exa --tree"
alias -- -='cd -'
alias 1='up 1'
alias 2='up 2'
alias 3='up 3'
alias 4='up 4'
alias 5='up 5'
alias 6='up 6'
alias 7='up 7'
alias 8='up 8'
alias 9='up 9'
# ###########################################################
# # Custom ENV vars
export GOCACHE=/tmp
export GOSUMDB=off
###########################################################
# Starts https://starship.rs
eval "$(starship init zsh)"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
###########################################################
# atuin (history)
atuin-setup() {
! hash atuin && return
export ATUIN_NOBIND="true"
eval "$(atuin init zsh)"
fzf-atuin-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2>/dev/null
selected=$(atuin search --cmd-only --limit ${ATUIN_LIMIT:-5000} | tac |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort,ctrl-z:ignore $FZF_CTRL_R_OPTS --query=${LBUFFER} +m" fzf)
local ret=$?
if [ -n "$selected" ]; then
# the += lets it insert at current pos instead of replacing
LBUFFER+="${selected}"
fi
zle reset-prompt
return $ret
}
zle -N fzf-atuin-history-widget
bindkey '^E' _atuin_search_widget
bindkey '^R' fzf-atuin-history-widget
bindkey '^[[A' fzf-atuin-history-widget
}
atuin-setup
bindkey '^ ' autosuggest-accept
_zsh_autosuggest_strategy_atuin_top() {
suggestion=$(atuin search --cmd-only --limit 1 --search-mode prefix $1)
}
ZSH_AUTOSUGGEST_STRATEGY=atuin_top
###########################################################
# Kubectl
export KUBECONFIG=~/.kube/config
export AWS_PROFILE="TXBTurboshopDeveloperAccess-440308253360"
###########################################################
# functions
gli() {
local filter
if [ -n $@ ] && [ -f $@ ]; then
filter="-- $@"
fi
git log \
--graph --color=always --abbrev=7 --format='%C(auto)%h %an %C(blue)%s %C(yellow)%cr' $@ | \
fzf \
--ansi --no-sort --reverse --tiebreak=index \
--preview "f() { set -- \$(echo -- \$@ | grep -o '[a-f0-9]\{7\}'); [ \$# -eq 0 ] || git show --color=always \$1 $filter; }; f {}" \
--bind "j:down,k:up,alt-j:preview-down,alt-k:preview-up,ctrl-f:preview-page-down,ctrl-b:preview-page-up,q:abort,ctrl-m:execute:
(grep -o '[a-f0-9]\{7\}' | head -1 |
xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF'
{}
FZF-EOF" \
--preview-window=right:60% \
--height 80%
}