-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
133 lines (112 loc) · 4.53 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
############################################################
# PATH
############################################################
export PATH=$PATH:~/.scripts:~/.local/bin
command -v go > /dev/null 2>&1 && export GOPATH=$(go env GOPATH) && export PATH=$PATH:$GOPATH/bin
############################################################
# Shell options
############################################################
HISTFILE=~/.cache/zsh/history
HISTSIZE=100000
SAVEHIST=$HISTSIZE
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt APPEND_HISTORY # Write to the history file when the shell exits, so they aren't shared across shells.
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 vi
# https://stackoverflow.com/questions/78444358/backspace-does-not-work-on-vim-mode-in-mac-os-terminal
bindkey -M viins "^?" backward-delete-char
############################################################
# Aliases
############################################################
export VISUAL=nvim
export EDITOR="$VISUAL"
export LESS="-FRX"
alias ll="ls -la"
alias e="exit"
alias v="vim"
alias n="nvim"
alias ssh="env TERM=xterm-256color ssh"
############################################################
# Env-specific setup
############################################################
env_init() {
command -v nodenv > /dev/null 2>&1 && eval "$(nodenv init -)"
# Set QT theme if in GNOME
[ "$XDG_CURRENT_DESKTOP" = "KDE" ] || [ "$XDG_CURRENT_DESKTOP" = "GNOME" ] || export QT_QPA_PLATFORMTHEME="qt5ct"
# Stripe stuff
if [[ "$HOST" == st-kyeb* ]]; then
# Recommended by go/zsh
if [[ -f ~/.stripe/shellinit/zshrc ]]; then
source ~/.stripe/shellinit/zshrc
fi
# Personal
export PATH=$PATH:$HOME/stripe/scripts:$HOME/stripe/gh-cli/bin
source ~/stripe/scripts/stripe-aliases.zsh
fi
# WSL setup
if [[ -d /mnt/wsl ]]; then
echo 'setting up WSL display...'
# https://stackoverflow.com/a/64233268
export DISPLAY_NUMBER="0.0"
export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):$DISPLAY_NUMBER
export LIBGL_ALWAYS_INDIRECT=1
fi
if [[ -d /opt/homebrew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
}
zoxide_init() {
if command -v zoxide > /dev/null 2>&1; then
eval "$(zoxide init zsh)"
fi
}
fzf_init() {
# Set up fzf
# The zinit fancy way of doing this always pulls keybindings from latest master,
# which sometimes introduces compatibility problems
export FZF_DEFAULT_COMMAND='rg --files'
if [ -f ~/.fzf.zsh ]; then
source ~/.fzf.zsh
fi
if [ -f /usr/share/fzf/key-bindings.zsh ]; then
source /usr/share/fzf/key-bindings.zsh
source /usr/share/fzf/completion.zsh
fi
if [ -f /usr/share/doc/fzf/examples/key-bindings.zsh ]; then
source /usr/share/doc/fzf/examples/key-bindings.zsh
source /usr/share/doc/fzf/examples/completion.zsh
fi
}
#################################
# Plugins
#################################
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
source "${ZINIT_HOME}/zinit.zsh"
# Prompt first
zinit ice compile'(pure|async).zsh' pick'async.zsh' src'pure.zsh'
zinit load sindresorhus/pure
# Prompt config
PURE_GIT_PULL=0
PURE_GIT_UNTRACKED_DIRTY=0
# Heavily used plugins; load them first
zinit wait'1' lucid for \
OMZ::plugins/git/git.plugin.zsh
zinit ice wait'1' lucid id-as"zoxide-init" atload'zoxide_init'
zinit light zdharma-continuum/null
# Important but not used constantly
zi wait'2' lucid for \
zdharma-continuum/fast-syntax-highlighting
zinit ice wait'2' lucid id-as"fzf-init" atload'fzf_init'
zinit light zdharma-continuum/null
# Lazy-loaded bits that are useful but can wait a few seconds before loading
zinit ice wait'3' lucid id-as"env-init" atload'env_init'
zinit light zdharma-continuum/null