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