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