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 HISTFILE="$XDG_STATE_HOME"/zsh/history
39export ZDOTDIR="$HOME"/.config/zsh
40export WINEPREFIX="$XDG_DATA_HOME"/wine
41export WORKON_HOME="$XDG_DATA_HOME/virtualenvs"
42export SQLITE_HISTORY="$XDG_CACHE_HOME"/sqlite_history
43export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle
44export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
45export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
46export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages
47export DVDCSS_CACHE="$XDG_DATA_HOME"/dvdcss
48export KDEHOME="$XDG_CONFIG_HOME"/kde
49export GOPATH="$XDG_DATA_HOME"/go
50export GNUPGHOME="$XDG_DATA_HOME"/gnupg
51export ZIM_HOME="$XDG_CONFIG_HOME"/.zim
52alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts"
53alias svn="svn --config-dir $XDG_CONFIG_HOME/subversion"
54
55eval "$(antidot init)"
56
57# ------------------
58# Initialize modules
59# ------------------
60if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
61 # Download zimfw script if missing.
62 command mkdir -p ${ZIM_HOME}
63 if (( ${+commands[curl]} )); then
64 command curl -fsSL -o ${ZIM_HOME}/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
65 else
66 command wget -nv -O ${ZIM_HOME}/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
67 fi
68fi
69if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
70 # Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
71 source ${ZIM_HOME}/zimfw.zsh init -q
72fi
73source ${ZIM_HOME}/init.zsh
74
75# ------------------------------
76# Post-init module configuration
77# ------------------------------
78
79# Plugins
80source /usr/share/zsh/scripts/zplug/init.zsh
81zplug 'endaaman/lxd-completion-zsh'
82if ! zplug check --verbose; then
83 printf "Install? [y/N]: "
84 if read -q; then
85 echo; zplug install
86 fi
87fi
88zplug load
89
90# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
91bindkey '^[[A' history-substring-search-up
92bindkey '^[[B' history-substring-search-down
93
94# Bind up and down keys
95zmodload -F zsh/terminfo +p:terminfo
96if [[ -n ${terminfo[kcuu1]} && -n ${terminfo[kcud1]} ]]; then
97 bindkey ${terminfo[kcuu1]} history-substring-search-up
98 bindkey ${terminfo[kcud1]} history-substring-search-down
99fi
100
101bindkey '^P' history-substring-search-up
102bindkey '^N' history-substring-search-down
103bindkey -M vicmd 'k' history-substring-search-up
104bindkey -M vicmd 'j' history-substring-search-down
105# End configuration added by Zim install
106
107# Executable paths
108export PATH="$PATH:$HOME/dotfiles/bin"
109export PATH="$PATH:$HOME/.emacs.d/bin"
110export PATH="$PATH:$HOME/.cargo/bin"
111export PATH="$PATH:$HOME/.local/bin"
112export ANDROID_HOME="$HOME/SDKs/Android"
113export PATH="$PATH:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator"
114export PATH="$PATH:$HOME/.gem/ruby/2.7.0/bin"
115export PATH="$PATH:$HOME/.gem/ruby/3.0.0/bin"
116export PATH="$PATH:$GOPATH/bin"
117export PATH="{{ .chezmoi.homeDir }}/perl5/bin${PATH:+:${PATH}}"; export PATH;
118export PERL5LIB="{{ .chezmoi.homeDir }}/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
119export PERL_LOCAL_LIB_ROOT="{{ .chezmoi.homeDir }}/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
120export PERL_MB_OPT="--install_base \"{{ .chezmoi.homeDir }}/perl5\""; export PERL_MB_OPT;
121export PERL_MM_OPT="INSTALL_BASE={{ .chezmoi.homeDir }}/perl5"; export PERL_MM_OPT;
122
123# Additional preferences
124export LANG=en_GB.UTF-8
125export EDITOR='devour emacsclient -c'
126export VISUAL='devour emacsclient -c'
127export _JAVA_AWT_WM_NONREPARENTING=1
128export MANPAGER="nvim +Man!"
129export COLUMNS=80
130export MANWIDTH=80
131
132CASE_SENSITIVE="false"
133
134# Disable dumb Python keyring integration
135export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
136
137#HYPHEN_INSENSITIVE="true"
138# Uncomment the following line if pasting URLs and other text is messed up.
139# DISABLE_MAGIC_FUNCTIONS=true
140
141# Additional completions
142compctl -g '~/.teamocil/*(:t:r)' teamocil
143
144# Integrate z - jump around
145source /usr/share/z/z.sh
146
147# Integrate FZF
148source /usr/share/fzf/key-bindings.zsh
149source /usr/share/fzf/completion.zsh
150
151# Conda crap
152[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh
153
154# Ranger conf
155export RANGER_LOAD_DEFAULT_RC=false
156
157# Bunch of aliases
158alias tmateqr='tmate show-messages | tail -n 1 | qrencode -o - -t ANSIUTF8'
159alias info="info --vi-keys"
160alias datetime="date +%Y-%m-%d_%H%M%S_%Z"
161alias e="$EDITOR"
162alias u="linx-client"
163alias clip="xclip -selection clipboard"
164alias tmp="cd $(mktemp -d)"
165alias send="rsync -avmzzP"
166alias tree="exa --tree"
167alias bat="bat -n --theme base16 --tabs 2"
168alias mov="ranger ~/Bulk/Media/Movies"
169alias tv="ranger ~/Bulk/Media/TV\ Shows"
170alias yt="ranger ~/Bulk/Media/YouTube"
171alias pass='str="$(pwgen -s 25 1)" && echo "$str" && echo -n "$str" | xclip -selection clipboard'
172alias secluded="cd ~/repos/personal/secluded && hugo --cleanDestinationDir && rsync -avmzz public/ hel1:/var/www/secluded/"
173alias erase="shred -vzfun 32"
174alias 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'"
175alias us="unsilence -t 15 -as 1.25"
176alias roll="roll -v"
177alias sxiv="sxiv -p"
178alias tt="tasktimer"
179alias c="chezmoi"
180alias t="todo"
181alias h="hledger"
182
183# Additional functions
184function gi() {
185 curl -sLw https://www.toptal.com/developers/gitignore/api/$@ ;
186}
187function noti() {
188 curl 'https://notify.nixnet.services/message?token={{- .gotify_token -}}' -F "title=$1" -F "message=$2" -F "priority=4"
189}
190# Hide the terminal when these apps are opened from a terminal
191function zathura() { devour zathura "$1" }
192function inkscape() { devour inkscape "$1" }
193
194autoload -U +X bashcompinit && bashcompinit
195
196# Necessary for SSH & YubiKey
197export GPG_TTY="$TTY"
198export SSH_AUTH_SOCK="/run/user/1000/gnupg/S.gpg-agent.ssh"
199gpgconf --launch gpg-agent
200
201eval "$(starship init zsh)"
202
203zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
204zstyle ':completion:*' group-name ''
205zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
206zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
207zstyle ':completion:*' menu select=1
208zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
209zstyle :compinstall filename '/home/amolith/.config/zsh/.zshrc'
210
211autoload -Uz compinit
212compinit
213compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"