config/user/.config/zsh/.zshrc

81 lines
2.4 KiB
Bash

# vars used for config
zsh_cache="${XDG_CACHE_HOME:-$HOME/.cache}/zsh"
[ -d "$zsh_cache" ] || mkdir -p "$zsh_cache"
zsh_config="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
[ -d "$zsh_config" ] || mkdir -p "$zsh_config"
zsh_plugins="${XDF_DATA_HOME:-$HOME/.local/share}/zsh/plugins"
[ -d "$zsh_plugins" ] || mkdir -p "$zsh_plugins"
# enable Powerlevel10k instant prompt - should stay close to the top
if [[ -r "$zsh_cache/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "$zsh_cache/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# basic options
setopt autocd
setopt interactive_comments
unsetopt beep
stty stop undef
autoload -U colors && colors
PS1="%B%{$fg[blue]%}%n%{$fg[cyan]%}@%{$fg[blue]%}%M %{$fg[cyan]%}%~ >%{$reset_color%} "
# history
HISTFILE=$zsh_cache/hist
HISTSIZE=10000000000
SAVEHIST=1000000
# tab complete
autoload -Uz compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit -d "$zsh_cache/zcompdump"
_comp_options+=(globdots) # include hidden files.
# use vim keybinds
bindkey -v
export KEYTIMEOUT=1
# vim keys in completion menu
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char
bindkey '^[[P' delete-char
# change cursor shape for different vi modes.
function zle-keymap-select () {
case $KEYMAP in
vicmd) echo -ne '\e[1 q';; # block
viins|main) echo -ne '\e[5 q';; # beam
esac
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
# Edit line in vim with ctrl-e:
autoload edit-command-line; zle -N edit-command-line
bindkey '^e' edit-command-line
bindkey -M vicmd '^[[P' vi-delete-char
bindkey -M vicmd '^e' edit-command-line
bindkey -M visual '^[[P' vi-delete
# Load aliases
source "$zsh_config/alias"
# source plugin configs
source "$zsh_config/p10k.zsh"
# source plugins
[ "$TERM" != 'linux' ] && source "$zsh_plugins/powerlevel10k/powerlevel10k.zsh-theme"
source "$zsh_plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
source "$zsh_plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
neofetch