1# Theming
2{{- if eq .theme_variant "dark" }}
3# https://github.com/catppuccin/zsh-syntax-highlighting
4source ~/.config/zsh/themes/catppuccin-macchiato.zsh
5export BAT_THEME="Catppuccin-macchiato"
6{{- end }}
7{{- if eq .theme_variant "light" }}
8# https://github.com/catppuccin/zsh-syntax-highlighting
9source ~/.config/zsh/themes/catppuccin-latte.zsh
10export BAT_THEME="Catppuccin-latte"
11{{- end }}
12
13# Remove older command from the history if a duplicate is to be added.
14setopt HIST_IGNORE_ALL_DUPS
15# Prompt for spelling correction of commands.
16setopt CORRECT
17# Customize spelling correction prompt.
18SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
19# Remove path separator from WORDCHARS.
20WORDCHARS=${WORDCHARS//[\/]}
21# Use degit instead of git as the default tool to install and update modules.
22zstyle ':zim:zmodule' use 'degit'
23# Set a custom prefix for the generated aliases. The default prefix is 'G'.
24#zstyle ':zim:git' aliases-prefix 'g'
25# Append `../` to your input for each `.` you type after an initial `..`
26zstyle ':zim:input' double-dot-expand no
27# Set a custom terminal title format using prompt expansion escape sequences.
28# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
29# If none is provided, the default '%n@%m: %~' is used.
30zstyle ':zim:termtitle' hooks 'preexec' 'precmd'
31zstyle ':zim:termtitle:preexec' format '${${(A)=1}[1]}'
32zstyle ':zim:termtitle:precmd' format '%1~'
33# Customize the style that the suggestions are shown with.
34# Set what highlighters will be used.
35# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
36ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
37# Customize the main highlighter styles.
38# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it
39#typeset -A ZSH_HIGHLIGHT_STYLES
40#ZSH_HIGHLIGHT_STYLES[comment]='fg=242'
41
42# XDG variables
43export XDG_DATA_HOME="$HOME/.local/share"
44export XDG_CONFIG_HOME="$HOME/.config"
45export XDG_STATE_HOME="$HOME/.local/state"
46export XDG_CACHE_HOME="$HOME/.cache"
47export XDG_BIN_HOME="$HOME/.local/bin"
48
49# Moving dotfiles around
50zstyle ':completion:*' cache-path "$XDG_CACHE_HOME"/zsh/zcompcache
51export ZDOTDIR="$HOME"/.config/zsh
52export WINEPREFIX="$XDG_DATA_HOME"/wine
53export WORKON_HOME="$XDG_DATA_HOME/virtualenvs"
54export SQLITE_HISTORY="$XDG_CACHE_HOME"/sqlite_history
55export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle
56export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
57export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
58export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages
59export DVDCSS_CACHE="$XDG_DATA_HOME"/dvdcss
60export KDEHOME="$XDG_CONFIG_HOME"/kde
61export GOPATH="$XDG_DATA_HOME"/go
62export ZIM_HOME="$XDG_CONFIG_HOME"/.zim
63export GHCUP_USE_XDG_DIRS="ishouldjustbeabletoexportthisnotsetit"
64alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts"
65alias svn="svn --config-dir $XDG_CONFIG_HOME/subversion"
66
67# ------------------
68# Initialize modules
69# ------------------
70if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
71 # Download zimfw script if missing.
72 command mkdir -p ${ZIM_HOME}
73 if (( ${+commands[curl]} )); then
74 command curl -fsSL -o ${ZIM_HOME}/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
75 else
76 command wget -nv -O ${ZIM_HOME}/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
77 fi
78fi
79if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
80 # Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
81 source ${ZIM_HOME}/zimfw.zsh init -q
82fi
83source ${ZIM_HOME}/init.zsh
84
85# ------------------------------
86# Post-init module configuration
87# ------------------------------
88
89# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
90bindkey '^[[A' history-substring-search-up
91bindkey '^[[B' history-substring-search-down
92
93# Bind up and down keys
94zmodload -F zsh/terminfo +p:terminfo
95if [[ -n ${terminfo[kcuu1]} && -n ${terminfo[kcud1]} ]]; then
96 bindkey ${terminfo[kcuu1]} history-substring-search-up
97 bindkey ${terminfo[kcud1]} history-substring-search-down
98fi
99
100bindkey '^P' history-substring-search-up
101bindkey '^N' history-substring-search-down
102bindkey -M vicmd 'k' history-substring-search-up
103bindkey -M vicmd 'j' history-substring-search-down
104# End configuration added by Zim install
105
106# Ruby crap
107eval "$(rbenv init - zsh)"
108export GEM_HOME="$(gem env user_gemhome)"
109export PATH="$PATH:$GEM_HOME/bin"
110eval "$(rbenv init -)"
111
112# Android crap
113export ANDROID_HOME="$XDG_DATA_HOME/Android"
114export ANDROID_SDK_ROOT="$ANDROID_HOME"
115export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator"
116
117# Executable paths
118export PATH="$PATH:$XDG_CONFIG_HOME/emacs/bin"
119export PATH="$PATH:$HOME/.gem/ruby/3.0.0/bin"
120export PATH="$PATH:$GOPATH/bin"
121export PATH="$PATH:$CACHE/yay/distrobox/pkg/distrobox/usr/bin"
122export PATH="$PATH:$XDG_DATA_HOME/cargo/bin"
123export PATH="$PATH:$HOME/.radicle/bin"
124export PATH="$HOME/.local/bin:$PATH"
125
126# Additional preferences
127export LANG=en_GB.UTF-8
128export EDITOR='emacsclient -c'
129export VISUAL='emacsclient -c'
130export _JAVA_AWT_WM_NONREPARENTING=1
131export MANPAGER="nvim +Man!"
132export COLUMNS=80
133export MANWIDTH=80
134export CHARM_HOST=charm.secluded.site
135export RIPGREP_CONFIG_PATH="$HOME/.config/ripgreprc"
136
137# Partially in response to https://sourcehut.org/blog/2023-01-09-gomodulemirror/
138# Partially because GOPROXY bad
139export GOPROXY=direct
140
141CASE_SENSITIVE="false"
142
143# Disable dumb Python keyring integration
144export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
145
146# Authenticate to Bitwarden
147export BW_SESSION="{{ .bw_session }}"
148
149# Authenticate to OpenAI
150export OPENAI_API_KEY="{{- .openai_api_key -}}"
151
152# Authenticate to local Radicle (.xyz) node
153export RAD_PASSWORD='{{ (bitwarden "item" "ded65872-71a1-4cdd-8e13-b12a00f84163").login.password }}'
154
155#HYPHEN_INSENSITIVE="true"
156# Uncomment the following line if pasting URLs and other text is messed up.
157# DISABLE_MAGIC_FUNCTIONS=true
158
159# Integrate z - jump around
160source /usr/share/z/z.sh
161
162# Integrate FZF
163source /usr/share/fzf/key-bindings.zsh
164source /usr/share/fzf/completion.zsh
165
166# Ranger conf
167export RANGER_LOAD_DEFAULT_RC=false
168
169# Bunch of aliases
170alias joe="joe-gitignore"
171alias ts="tailscale"
172alias tmateqr='tmate show-messages | tail -n 1 | qrencode -o - -t ANSIUTF8'
173alias info="info --vi-keys"
174alias datetime="date +%Y-%m-%d_%H%M%S_%Z"
175alias e="$EDITOR"
176alias u="linx-client"
177alias clip="xclip -selection clipboard"
178alias tmp="cd $(mktemp -d) && export TEMP=$(pwd)"
179alias send="rsync -amzzP"
180alias tree="eza --tree"
181alias bat="bat -n --tabs 2"
182alias mov="joshuto ~/Bulk/Media/Movies"
183alias tv="joshuto ~/Bulk/Media/TV\ Shows"
184alias yt="joshuto ~/Bulk/Media/YouTube"
185alias erase="shred -vzfun 32"
186alias dl="yt-dlp -f bestvideo+bestaudio --write-sub --write-auto-sub --sub-lang en --sub-format srt/best --convert-subs srt --embed-subs -o '%(upload_date)s %(title)s.%(ext)s'"
187alias us="unsilence -t 15 -as 1.25"
188alias roll="roll -v"
189alias sxiv="sxiv -p"
190alias c="chezmoi"
191alias t="tea"
192alias j="just"
193alias ac="aicommits"
194alias tc="turbocommit"
195alias ai="sgpt"
196alias k="klog"
197
198# Blog-related aliases
199alias secluded="cd ~/repos/personal/secluded && ./gen"
200alias drafts='e $(rg -l "draft: true" $HOME/repos/personal/secluded | fzf --preview "bat --color=always {}" --preview-window "~3")'
201
202# Custom functions
203function pass() {
204 bw get password $@ | xclip -selection clipboard
205}
206function gi() {
207 curl -sLw https://www.toptal.com/developers/gitignore/api/$@ ;
208}
209
210# Navi integration
211_call_navi() {
212 local selected
213 if selected="$(printf "$(navi --print --path ${XDG_DATA_HOME}/navi/cheats </dev/tty)")"; then
214 LBUFFER="$selected"
215 fi
216 zle redisplay
217}
218zle -N _call_navi
219bindkey '^n' _call_navi
220
221zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
222zstyle ':completion:*' group-name ''
223zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
224zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
225zstyle ':completion:*' menu select=1
226zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
227zstyle :compinstall filename '/home/amolith/.config/zsh/.zshrc'
228
229# Additional completions
230source $XDG_CONFIG_HOME/zsh/completions/charm.zsh
231source $XDG_CONFIG_HOME/zsh/completions/starship.zsh
232source $XDG_CONFIG_HOME/zsh/completions/antidot.zsh
233source $XDG_CONFIG_HOME/zsh/completions/klog.zsh
234source $XDG_CONFIG_HOME/zsh/completions/chezmoi.zsh
235
236# Configure history file
237export HISTFILE="$XDG_STATE_HOME"/zsh/history
238export HISTSIZE=1000000
239export SAVEHIST=1000000
240
241autoload -Uz compinit && compinit
242autoload -U +X bashcompinit && bashcompinit
243
244compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"