-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
204 lines (162 loc) · 5.94 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
# Run tmux if exists
if [[ -x "$(command -v tmux)" ]]; then
[ -z "${TMUX}" ] && exec tmux
else
echo "tmux not installed on this system"
fi
# zmodload zsh/zprof
# various zsh options
zstyle ':completion:*' menu select
zmodload zsh/complist
bindkey -M menuselect '^[[Z' reverse-menu-complete
# Turn off stupid beep!
unsetopt BEEP
# ---------------------------------------------------------
# history
# ---------------------------------------------------------
HISTFILE=$DOTFILES/.local/zsh_history
SAVEHIST=100000
HISTSIZE=100000
setopt INC_APPEND_HISTORY
setopt histignoredups
zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 }
# ---------------------------------------------------------
# Plugins
# ---------------------------------------------------------
# If autojump installed, source the provided shell script.
if [ -x $(command -v autojump) ]; then
if [ -f "/etc/debian_version" ]; then
source /usr/share/autojump/autojump.sh
elif [[ "$OSTYPE" == "darwin"* ]] then
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
#source /opt/homebrew/share/autojump/autojump.zsh
elif [ -f "/etc/arch-release" ]; then
source /usr/share/autojump/autojump.zsh
fi
fi
# Source FZF if installed
# Manual
if [ -f ~/.fzf.zsh ]; then
source ~/.fzf.zsh
# Debian
elif [ -f /usr/share/doc/fzf/examples/completion.zsh ]; then
source /usr/share/doc/fzf/examples/key-bindings.zsh
source /usr/share/doc/fzf/examples/completion.zsh
# Arch
elif [ -r /etc/arch-release ]; then
source /usr/share/fzf/completion.zsh
source /usr/share/fzf/key-bindings.zsh
elif [ -r /opt/homebrew/opt/fzf ]; then
source /opt/homebrew/opt/fzf/shell/completion.zsh
source /opt/homebrew/opt/fzf/shell/key-bindings.zsh
elif [ -r /usr/local/opt/fzf/shell/completion.zsh ]; then
source /usr/local/opt/fzf/shell/completion.zsh
source /usr/local/opt/fzf/shell/key-bindings.zsh
fi
#Plugins
source_plugin() {
local source_file="$1.plugin.zsh"
# Use second argument as filename if provided
if [[ ! -z $2 ]]; then
source_file=$2
fi
[[ -d $ZSH_PLUGINS/$1 ]] && source "$ZSH_PLUGINS/$1/$source_file"
}
# Place github path for plugins to be installed here.
plugins=(
"zsh-users/zsh-autosuggestions"
"zsh-users/zsh-syntax-highlighting"
"zsh-users/zsh-completions"
"zsh-users/zsh-history-substring-search"
"LudvigHz/k"
)
# Oh-my-zsh plugins to be installed
oh_my_zsh_plugins=(
"sudo"
)
# To source the plugins above, use the source_plugin command
# if the filename is different from <plugin>.plugin.zsh
# use second argument as filename.
source_plugin zsh-autosuggestions
source_plugin zsh-syntax-highlighting
source_plugin zsh-completions
source_plugin zsh-history-substring-search
source_plugin k "k.sh"
source_plugin sudo
# ---------------------------------------------------------
# Path
# ---------------------------------------------------------
export PATH="/usr/local/texlive/2020/bin/x86_64-linux:$PATH"
export PATH="/home/ludvig/.local/share/coursier/bin:$HOME/.cabal/bin:$PATH"
export PATH="$HOME/.yarn/bin:$HOME/go/bin:/usr/local/go/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.bun/bin:$PATH"
# Godamm brew
export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"
export CPPFLAGS="-I/opt/homebrew/opt/openjdk@17/include"
export PATH="/Users/ludvig/.local/share/containers/podman-desktop/extensions-storage/podman-desktop.compose/bin:$PATH"
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
export PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"
# ---------------------------------------------------------
# Environment
# ---------------------------------------------------------
export EDITOR=nvim
export PASSWORD_STORE_ENABLE_EXTENSIONS=true
export LESS='-+F -S -R -M -i'
# launch gpg-agent with ssh support
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
# use ripgrep for fzf
# Respect gitignores and always ignore module directories
export FZF_DEFAULT_COMMAND="rg --files --follow --ignore-vcs -g '!{node_modules,venv}'"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# ---------------------------------------------------------
# Prompt
# ---------------------------------------------------------
source $DOTFILES/prompt.zsh
# ---------------------------------------------------------
# Aliases
# ---------------------------------------------------------
source $DOTFILES/aliases.zsh
# ---------------------------------------------------------
# Functions
# ---------------------------------------------------------
source $DOTFILES/functions.zsh
# ---------------------------------------------------------
# Compinit (Completion initialization)
# ---------------------------------------------------------
# Completions not provided by plugins or bundled can be put here
fpath=("$DOTFILES/.local/completions" "/opt/homebrew/share/zsh/site-functions" $fpath)
_zpcompinit_custom() {
# Remember to have "skip_global_compinit=1" in $ZDOTDIR:-$HOME/.zshenv
# otherwise zsh calls compinit by itself and generates a new dumpfile,
# ruining the whole point of the cache...
setopt extendedglob local_options
autoload -Uz compinit
local zcd=${ZDOTDIR:-$HOME}/.zcompdump
local zcdc="$zcd.zwc"
# If the completion dump is older than 24h
if [[ -f "$zcd"(#qN.m+1) ]]; then
compinit -i -d "$zcd" # Run compinit and specify compdump to $zcd
compdump # Force call compdump (should not be neccasary)
{ rm -f "$zcdc" && zcompile "$zcd" } &! # Remove and recompile
else
compinit -C "$zcd" # Only check the cache usually
fi
unsetopt extendedglob
}
_zpcompinit_custom
# Reload completions. Useful for loading new completions.
# Otherwise they are not loaded until the next day
compload() {
setopt extendedglob local_options
local zcd=${ZDOTDIR:-$HOME}/.zcompdump
local zcdc="$zcd.zwc"
rm -f "$zcdc" "$zcd"
_zpcompinit_custom
}
# Call zprof (debug)
#zprof
eval "$(direnv hook zsh)"