private_dot_zshrc.tmpl

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