private_dot_zshrc.tmpl

  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"
 47
 48# Moving dotfiles around
 49zstyle ':completion:*' cache-path "$XDG_CACHE_HOME"/zsh/zcompcache
 50export ZDOTDIR="$HOME"/.config/zsh
 51export WINEPREFIX="$XDG_DATA_HOME"/wine
 52export WORKON_HOME="$XDG_DATA_HOME/virtualenvs"
 53export SQLITE_HISTORY="$XDG_CACHE_HOME"/sqlite_history
 54export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle
 55export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
 56export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
 57export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages
 58export DVDCSS_CACHE="$XDG_DATA_HOME"/dvdcss
 59export KDEHOME="$XDG_CONFIG_HOME"/kde
 60export GOPATH="$XDG_DATA_HOME"/go
 61export ZIM_HOME="$XDG_CONFIG_HOME"/.zim
 62alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts"
 63alias svn="svn --config-dir $XDG_CONFIG_HOME/subversion"
 64
 65# ------------------
 66# Initialize modules
 67# ------------------
 68if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
 69  # Download zimfw script if missing.
 70  command mkdir -p ${ZIM_HOME}
 71  if (( ${+commands[curl]} )); then
 72    command curl -fsSL -o ${ZIM_HOME}/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
 73  else
 74    command wget -nv -O ${ZIM_HOME}/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
 75  fi
 76fi
 77if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
 78  # Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
 79  source ${ZIM_HOME}/zimfw.zsh init -q
 80fi
 81source ${ZIM_HOME}/init.zsh
 82
 83# ------------------------------
 84# Post-init module configuration
 85# ------------------------------
 86
 87# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
 88bindkey '^[[A' history-substring-search-up
 89bindkey '^[[B' history-substring-search-down
 90
 91# Bind up and down keys
 92zmodload -F zsh/terminfo +p:terminfo
 93if [[ -n ${terminfo[kcuu1]} && -n ${terminfo[kcud1]} ]]; then
 94  bindkey ${terminfo[kcuu1]} history-substring-search-up
 95  bindkey ${terminfo[kcud1]} history-substring-search-down
 96fi
 97
 98bindkey '^P' history-substring-search-up
 99bindkey '^N' history-substring-search-down
100bindkey -M vicmd 'k' history-substring-search-up
101bindkey -M vicmd 'j' history-substring-search-down
102# End configuration added by Zim install
103
104# Executable paths
105export PATH="$PATH:$HOME/dotfiles/bin"
106export PATH="$PATH:$XDG_CONFIG_HOME/emacs/bin"
107export PATH="$PATH:$HOME/.local/bin"
108export PATH="$PATH:$HOME/.gem/ruby/2.7.0/bin"
109export PATH="$PATH:$HOME/.gem/ruby/3.0.0/bin"
110export PATH="$PATH:$GOPATH/bin"
111export PATH="$PATH:$CACHE/yay/distrobox/pkg/distrobox/usr/bin"
112export PATH="$PATH:$XDG_DATA_HOME/cargo/bin"
113
114# Android crap
115export ANDROID_HOME="$XDG_DATA_HOME/Android"
116export ANDROID_SDK_ROOT="$ANDROID_HOME"
117export PATH="$PATH:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator"
118
119# Additional preferences
120export LANG=en_GB.UTF-8
121export EDITOR='devour emacsclient -c'
122export VISUAL='devour emacsclient -c'
123export _JAVA_AWT_WM_NONREPARENTING=1
124export MANPAGER="nvim +Man!"
125export COLUMNS=80
126export MANWIDTH=80
127export CHARM_HOST=charm.secluded.site
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 Bitwarden
139export BW_SESSION="{{ .bw_session }}"
140
141# Authenticate to OpenAI
142export OPENAI_API_KEY="{{- .openai_api_key -}}"
143
144#HYPHEN_INSENSITIVE="true"
145# Uncomment the following line if pasting URLs and other text is messed up.
146# DISABLE_MAGIC_FUNCTIONS=true
147
148# Integrate z - jump around
149source /usr/share/z/z.sh
150
151# Integrate FZF
152#source /usr/share/fzf/key-bindings.zsh
153#source /usr/share/fzf/completion.zsh
154
155# Use atuin instead of FZF
156source "$XDG_CONFIG_HOME/zsh/init/atuin.zsh"
157
158# Conda crap
159[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh
160
161# Ranger conf
162export RANGER_LOAD_DEFAULT_RC=false
163
164# Bunch of aliases
165alias joe="joe-gitignore"
166alias ts="tailscale"
167alias tmateqr='tmate show-messages | tail -n 1 | qrencode -o - -t ANSIUTF8'
168alias info="info --vi-keys"
169alias datetime="date +%Y-%m-%d_%H%M%S_%Z"
170alias e="$EDITOR"
171alias u="linx-client"
172alias clip="xclip -selection clipboard"
173alias tmp="cd $(mktemp -d)"
174alias send="rsync -amzzP"
175alias tree="exa --tree"
176alias bat="bat -n --tabs 2"
177alias mov="ranger ~/Bulk/Media/Movies"
178alias tv="ranger ~/Bulk/Media/TV\ Shows"
179alias yt="ranger ~/Bulk/Media/YouTube"
180alias erase="shred -vzfun 32"
181alias 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'"
182alias us="unsilence -t 15 -as 1.25"
183alias roll="roll -v"
184alias sxiv="sxiv -p"
185alias c="chezmoi"
186alias t="tea"
187alias j="just"
188alias ac="aicommits"
189alias tc="turbocommit"
190alias ai="sgpt"
191
192# Blog-related aliases
193alias secluded="cd ~/repos/personal/secluded && ./gen"
194alias drafts='e $(rg -l "draft: true" $HOME/repos/personal/secluded | fzf --preview "bat --color=always {}" --preview-window "~3")'
195
196# Custom functions
197function pass() {
198         bw get password $@ | xclip -selection clipboard
199}
200function gi() {
201    curl -sLw https://www.toptal.com/developers/gitignore/api/$@ ;
202}
203function noti() {
204    curl 'https://notify.nixnet.services/message?token={{- .gotify_token -}}' -F "title=$1" -F "message=$2" -F "priority=4"
205}
206# Hide the terminal when these apps are opened from a terminal
207function zathura() { devour zathura "$1" }
208function inkscape() { devour inkscape "$1" }
209
210# Necessary for SSH & YubiKey
211export GPG_TTY="$TTY"
212export SSH_AUTH_SOCK="/run/user/1000/gnupg/S.gpg-agent.ssh"
213gpgconf --launch gpg-agent
214
215zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
216zstyle ':completion:*' group-name ''
217zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
218zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
219zstyle ':completion:*' menu select=1
220zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
221zstyle :compinstall filename '/home/amolith/.config/zsh/.zshrc'
222
223# Additional completions
224source $XDG_CONFIG_HOME/zsh/completions/charm.zsh
225source $XDG_CONFIG_HOME/zsh/completions/starship.zsh
226source $XDG_CONFIG_HOME/zsh/completions/antidot.zsh
227source $XDG_CONFIG_HOME/zsh/completions/atuin.zsh
228fpath=($XDG_CONFIG_HOME/zsh/completions/ $fpath)
229
230# Configure history file
231export HISTFILE="$XDG_STATE_HOME"/zsh/history
232export HISTSIZE=1000000
233export SAVEHIST=1000000
234
235bindkey '^[[A' history-substring-search-up
236bindkey '^[[B' history-substring-search-down
237
238autoload -Uz compinit && compinit
239autoload -U +X bashcompinit && bashcompinit
240
241compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"