1# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
2# Initialization code that may require console input (password prompts, [y/n]
3# confirmations, etc.) must go above this block; everything else may go below.
4if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
5 source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
6fi
7
8source ~/.config/p10k/powerlevel10k.zsh-theme
9
10# Remove older command from the history if a duplicate is to be added.
11setopt HIST_IGNORE_ALL_DUPS
12# Prompt for spelling correction of commands.
13setopt CORRECT
14# Customize spelling correction prompt.
15SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
16# Remove path separator from WORDCHARS.
17WORDCHARS=${WORDCHARS//[\/]}
18# Use degit instead of git as the default tool to install and update modules.
19zstyle ':zim:zmodule' use 'degit'
20# Set a custom prefix for the generated aliases. The default prefix is 'G'.
21#zstyle ':zim:git' aliases-prefix 'g'
22# Append `../` to your input for each `.` you type after an initial `..`
23zstyle ':zim:input' double-dot-expand yes
24# Set a custom terminal title format using prompt expansion escape sequences.
25# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
26# If none is provided, the default '%n@%m: %~' is used.
27zstyle ':zim:termtitle' hooks 'preexec' 'precmd'
28zstyle ':zim:termtitle:preexec' format '${${(A)=1}[1]}'
29zstyle ':zim:termtitle:precmd' format '%1~'
30# Customize the style that the suggestions are shown with.
31# Set what highlighters will be used.
32# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
33ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
34# Customize the main highlighter styles.
35# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it
36#typeset -A ZSH_HIGHLIGHT_STYLES
37#ZSH_HIGHLIGHT_STYLES[comment]='fg=242'
38
39# ------------------
40# Initialize modules
41# ------------------
42if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
43 # Download zimfw script if missing.
44 command mkdir -p ${ZIM_HOME}
45 if (( ${+commands[curl]} )); then
46 command curl -fsSL -o ${ZIM_HOME}/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
47 else
48 command wget -nv -O ${ZIM_HOME}/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
49 fi
50fi
51if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
52 # Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
53 source ${ZIM_HOME}/zimfw.zsh init -q
54fi
55source ${ZIM_HOME}/init.zsh
56
57# ------------------------------
58# Post-init module configuration
59# ------------------------------
60
61# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
62bindkey '^[[A' history-substring-search-up
63bindkey '^[[B' history-substring-search-down
64
65# Bind up and down keys
66zmodload -F zsh/terminfo +p:terminfo
67if [[ -n ${terminfo[kcuu1]} && -n ${terminfo[kcud1]} ]]; then
68 bindkey ${terminfo[kcuu1]} history-substring-search-up
69 bindkey ${terminfo[kcud1]} history-substring-search-down
70fi
71
72bindkey '^P' history-substring-search-up
73bindkey '^N' history-substring-search-down
74bindkey -M vicmd 'k' history-substring-search-up
75bindkey -M vicmd 'j' history-substring-search-down
76# End configuration added by Zim install
77
78# Executable paths
79export PATH="$PATH:$HOME/dotfiles/bin"
80export PATH="$PATH:$HOME/.emacs.d/bin"
81export PATH="$PATH:$HOME/.cargo/bin"
82export PATH="$PATH:$HOME/.local/bin"
83export ANDROID_HOME="$HOME/SDKs/Android"
84export PATH="$PATH:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator"
85export PATH="$PATH:$HOME/.gem/ruby/2.7.0/bin"
86export PATH="$PATH:$HOME/.gem/ruby/3.0.0/bin"
87export PATH="$PATH:$HOME/go/bin"
88export PATH="{{ .chezmoi.homeDir }}/perl5/bin${PATH:+:${PATH}}"; export PATH;
89export PERL5LIB="{{ .chezmoi.homeDir }}/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
90export PERL_LOCAL_LIB_ROOT="{{ .chezmoi.homeDir }}/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
91export PERL_MB_OPT="--install_base \"{{ .chezmoi.homeDir }}/perl5\""; export PERL_MB_OPT;
92export PERL_MM_OPT="INSTALL_BASE={{ .chezmoi.homeDir }}/perl5"; export PERL_MM_OPT;
93
94# Additional preferences
95export LANG=en_GB.UTF-8
96export EDITOR='devour emacsclient -c'
97export VISUAL='devour emacsclient -c'
98export _JAVA_AWT_WM_NONREPARENTING=1
99export MANPAGER="nvim +Man!"
100export COLUMNS=80
101export MANWIDTH=80
102
103CASE_SENSITIVE="false"
104
105# Disable dumb Python keyring integration
106export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
107
108#HYPHEN_INSENSITIVE="true"
109# Uncomment the following line if pasting URLs and other text is messed up.
110# DISABLE_MAGIC_FUNCTIONS=true
111
112# Additional completions
113compctl -g '~/.teamocil/*(:t:r)' teamocil
114
115# Integrate z - jump around
116source /usr/share/z/z.sh
117
118# Ranger conf
119export RANGER_LOAD_DEFAULT_RC=false
120
121# Bunch of aliases
122alias e="$EDITOR"
123alias u="linx-client"
124alias vim="nvim"
125alias tmp="cd $(mktemp -d)"
126alias send="rsync -avmzzP"
127alias tree="exa --tree"
128alias bat="bat -n --theme base16 --tabs 2"
129alias mov="ranger ~/Videos/Movies"
130alias tv="ranger ~/Videos/TV\ Shows"
131alias yt="ranger ~/Videos/YouTube"
132alias pass='str="$(pwgen -s 25 1)" && echo "$str" && echo -n "$str" | xclip -selection clipboard'
133alias secluded="cd ~/repos/sites/secluded/ && hugo --cleanDestinationDir && rsync -avmzz public/ hel1-srv1:/var/www/secluded/"
134alias erase="shred -vzfun 32"
135alias dl="youtube-dl -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'"
136alias us="unsilence -t 15 -as 1.25"
137alias roll="roll -v"
138alias dn="notify-send done"
139alias sxiv="sxiv -p"
140alias tt="tasktimer"
141alias c="chezmoi"
142alias t="todo"
143
144# Additional functions
145function gi() {
146 curl -sLw n https://www.toptal.com/developers/gitignore/api/$@ ;
147}
148function noti() {
149 curl 'https://notify.nixnet.services/message?token={{- .gotify_token -}}' -F "title=$1" -F "message=$2" -F "priority=4"
150}
151# Hide the terminal when these apps are opened from a terminal
152function zathura() { devour zathura "$1" }
153function inkscape() { devour inkscape "$1" }
154
155autoload -U +X bashcompinit && bashcompinit
156
157# Necessary for SSH & YubiKey
158export GPG_TTY="$TTY"
159export SSH_AUTH_SOCK="/run/user/1000/gnupg/S.gpg-agent.ssh"
160gpgconf --launch gpg-agent
161
162# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
163[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
164(( ! ${+functions[p10k]} )) || p10k finalize