-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc
154 lines (130 loc) · 4.81 KB
/
dot_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
# iterm2 integration
if [ -e "$HOME/.iterm2_shell_integration" ]; then
source "$HOME"/.iterm2_shell_integration.zsh
fi
# Homebrew completions
if type brew &>/dev/null; then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit
compinit
fi
# Antidote
ANTIDOTE="$(brew --prefix)/share/antidote"
if [ -d "$ANTIDOTE" ]; then
source "$ANTIDOTE/antidote.zsh"
# - load plugins
source "${HOME}/.zplugins.sh"
# - run zupdate when changing .zplugins
alias zupdate="antidote bundle < ~/.zplugins > ~/.zplugins.sh"
fi
# Aliases
if [ -x "$(command -v bat)" ]; then
alias cat='bat'
fi
if [ -x "$(command -v ncdu)" ]; then
alias du="ncdu --color dark -e -rr -x --exclude .git --exclude node_modules"
fi
if [ -x "$(command -v gh)" ]; then
alias ghcpub="gh create --confirm --public"
alias ghcprv="gh create --confirm --private"
alias gho="gh repo view -w"
fi
if [ -x "$(command -v eza)" ]; then
alias ls="eza"
alias ll="eza -al"
fi
alias chez="chezmoi"
# git aliases
aliasmsg() {
if [ -n "$2" ]; then
echo "$2"
fi
echo "➜ $1"
eval "$1"
}
alias gfom="git fetch origin main"
alias gswm="git switch main"
alias nah='aliasmsg "git reset --hard HEAD" "yeah, nah. ditch all that"'
alias yolo='aliasmsg "git add -A && git commit -m \"$(curl -s https://api.kanye.rest/ | jq '\''.quote'\'')\" "yolo commiting"'
# History Config
HISTFILE="$HOME/.zsh_history"
HISTSIZE=1000000
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
setopt HIST_BEEP # Beep when accessing nonexistent history.
# Set up fuzzy find
export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'
export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'" # add support for ctrl+o to open selected file in VS Code
[ -f ~/.fzf.zsh ] && source "${HOME}/.fzf.zsh"
# Set GPG TTY
export GPG_TTY=$TTY
# 1password completion
if [ -x "$(command -v op)" ]; then
eval "$(op completion zsh)"; compdef _op op
# 1Password Agent Symlink on macOS
if [[ "$(uname)" == "Darwin" ]]; then
# check if link has not been created and make sure that agent is enabled
if [ ! -L ~/.1password/agent.sock ] && [ -e "${HOME}/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" ]; then
# create symlink to 1password agent
mkdir -p ~/.1password && ln -s ~/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock ~/.1password/agent.sock
fi
fi
fi
# pyenv config
if [ -x "$(command -v pyenv)" ]; then
eval "$(pyenv init -)"
fi
# asdf + direnv
if [ -x "$(command -v asdf)" ]; then
if [ -x "$(command -v direnv)" ]; then
export ASDF_NODEJS_AUTO_ENABLE_COREPACK=true
eval "$(asdf exec direnv hook zsh)"
fi
fi
# pnpm
export PNPM_HOME="${HOME}/Library/pnpm"
export PATH="$PNPM_HOME:$PATH"
# go
if [ -x "$(command -v go)" ]; then
GOPATH="$(go env GOPATH)"
export PATH="$GOPATH/bin:$PATH"
fi
# wash completions
if [ -x "$(command -v wash)" ]; then
wash completions -d /tmp/ zsh >/dev/null
eval "$(/bin/cat /tmp/_wash)"
rm /tmp/_wash
fi
# wkg config
# remove once https://github.com/bytecodealliance/wasm-pkg-tools/issues/111 is resolved
export WKG_CONFIG_FILE=${HOME}/.config/wasm-pkg/config.toml
export WKG_CACHE_DIR=${HOME}/.cache
# export secret env variables from ~/.secrets
set -o allexport
if [ -f ~/.secrets ]; then source "${HOME}/.secrets"; fi
set +o allexport
# Load completion for brew installed apps
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C "$(which terraform)" terraform
complete -o nospace -C "$(which nomad)" nomad
complete -o nospace -C "$(which vault)" vault
complete -o nospace -C "$(which packer)" packer
complete -o nospace -C "$(which consul)" consul
# Load completions for google cloud sdk
if [ -x "$(command -v gcloud)" ]; then
source "$(brew --prefix)/share/google-cloud-sdk/path.zsh.inc"
source "$(brew --prefix)/share/google-cloud-sdk/completion.zsh.inc"
fi
# Load Nix profile
if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
source "$HOME/.nix-profile/etc/profile.d/nix.sh"
fi