-
Notifications
You must be signed in to change notification settings - Fork 1
/
.zshrc
201 lines (163 loc) · 4.86 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
#################################
# Exports
#################################
export RIPGREP_CONFIG_PATH="${HOME}/.ripgreprc"
# Paths
eval "$(/opt/homebrew/bin/brew shellenv)"
. "$HOME/.asdf/asdf.sh"
path+=("$HOME/bin")
path=("/usr/local/MacGPG2/bin" $path)
export PATH
export HOMEBREW_BUNDLE_FILE="${HOME}/.Brewfile"
if which nvim >/dev/null; then
EDITOR="nvim"
alias vim='nvim'
alias vi='nvim'
else
EDITOR="vim"
alias vi='vim'
fi
fpath+=($HOME/.zsh/pure)
fpath=(${ASDF_DIR}/completions $fpath)
# Java Home
. ~/.asdf/plugins/java/set-java-home.zsh
# Android SDK
export ANDROID_HOME="${HOMEBREW_PREFIX}/share/android-commandlinetools"
export ANDROID_SDK_ROOT="${ANDROID_HOME}"
path+=("${ANDROID_HOME}/emulator" "${ANDROID_HOME}/platform-tools")
export PATH
# Nix
[[ ! $(command -v nix) && -e "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]] && source "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
# Go
export PATH="${PATH}:$(go env GOPATH)/bin"
# gpg-agent
export GPG_TTY="$(tty)"
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
gpgconf --launch gpg-agent
export ROLES_WORKERS=1
# Dir Stacks
DIRSTACKSIZE=8
setopt autopushd pushdminus pushdsilent pushdtohome
#################################
# General
#################################
# Secrets - local settings
[[ -f ~/.secret ]] && source ~/.secret
autoload colors # enable colors
autoload -U compinit # enable auto completion
autoload -U promptinit # advanced prompts support
colors # initialize
compinit # longest wait
promptinit
prompt pure
export PURE_GIT_PULL=0
# History search
export HISTSIZE=4000 # number of lines kept in history
export SAVEHIST=4000 # number of lines saved in the history after logout
export HISTFILE="$HOME/.zsh_history" # location of history
setopt INC_APPEND_HISTORY # append command to history file once executed
setopt SHARE_HISTORY # for sharing history between zsh proce'ses
setopt HIST_IGNORE_ALL_DUPS # Ignore duplicates in history
setopt HIST_IGNORE_SPACE # don't record entry if a space is preceeding it
# Plugin manager
#eval "$(sheldon source)"
eval "$(direnv hook zsh)"
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /opt/homebrew/bin/terraform terraform
# Set up fzf key bindings and fuzzy completion
source <(fzf --zsh)
#################################
# Key Bindings
#################################
# ZLE bindings - VI
bindkey -v
# bash like ctrl-w
autoload -U select-word-style
select-word-style bash
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[[A" history-beginning-search-backward-end
bindkey "^[[B" history-beginning-search-forward-end
#################################
# Functions
#################################
# reload zshrc
function src() {
autoload -U zrecompile
[[ -f ~/.zshrc ]] && zrecompile -p ~/.zshrc
[[ -f ~/.zcompdump ]] && zrecompile -p ~/.zcompdump
[[ -f ~/.zcompdump ]] && zrecompile -p ~/.zcompdump
[[ -f ~/.zshrc.zwc.old ]] && rm -f ~/.zshrc.zwc.old
[[ -f ~/.zcompdump.zwc.old ]] && rm -f ~/.zcompdump.zwc.old
source ~/.zshrc
}
function b {
if [[ $# == 0 || $1 == "unlock" ]]; then
if [[ -f "${HOME}/.bwsession" ]]; then
source "${HOME}/.bwsession"
fi
if ! bw login --check; then
echo "Log in:"
bw login
fi
if ! bw unlock --check; then
BW_SESSION=$(bw --response unlock | jq '.data.raw')
export BW_SESSION
echo "export BW_SESSION=${BW_SESSION}" > "${HOME}/.bwsession"
fi
bw sync
else
bw "$@"
fi
}
function t {
if [[ $# == 0 ]]; then
terraform plan
else
terraform "$@"
fi
}
function select-work-dir() {
echo "${HOME}"
WORK_DIR="${HOME}/work"
SELECTED=$(ls "${WORK_DIR}" | fzf)
[[ -n "${SELECTED}" ]] && cd "${WORK_DIR}/${SELECTED}"
echo
zle reset-prompt
}
zle -N select-work-dir
bindkey '^a' select-work-dir
#################################
# Aliases
#################################
alias intel='echo x86_64; arch -x86_64 zsh; arch'
# git
alias gco='git checkout'
alias gl='git pull'
alias gst='git status'
alias gp='git push'
alias gd='git diff'
alias gds='git diff --staged'
alias ga='git add'
alias gc='git commit'
alias glg='git log'
alias glgo='git log --oneline'
alias glgp='git log --patch'
alias gf='git fetch'
alias gb='git branch'
# ls
alias l="ls -AF --color"
alias ll="ls -aFl --color"
# other
alias ..='cd ..'
alias h='fc -l 1'
alias rm='rm -i '
alias cp='cp -i '
alias mv='mv -i '
alias grep='grep -i --color'
alias df='df -h'
alias dirs='dirs -v'