zsh: split functionality into child files

This commit is contained in:
surtur 2023-09-08 14:12:40 +02:00
parent f758162425
commit 889fd62e17
Signed by: wanderer
SSH Key Fingerprint: SHA256:MdCZyJ2sHLltrLBp0xQO0O1qTW9BT/xl5nXkDvhlMCI
4 changed files with 54 additions and 42 deletions

21
.zsh/bindings.zsh Normal file

@ -0,0 +1,21 @@
# as per https://github.com/jeffreytse/zsh-vi-mode#execute-extra-commands
function zvm_after_lazy_keybindings() {
# map Del escape sequence to actual Del key in all (n,i) modes to resemble vim instead of vi
bindkey -a '^[[3~' delete-char
# map arrow up/down to control fish-like history substring search and highlighting
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey '^o' fzf-open
# also map the same keys in 'viins' (INSERT) mode...
bindkey -M viins '^[[A' history-substring-search-up
bindkey -M viins '^[[B' history-substring-search-down
bindkey -M viins '^o' fzf-open
# ...and in 'vicmd' (NORMAL) mode...
bindkey -M vicmd '^[[A' history-substring-search-up
bindkey -M vicmd '^[[B' history-substring-search-down
# ...and as well to K, J, instead of arrow up/down, respectively.
# note these are capital letters, original behaviour of j, k is left unchanged
bindkey -M vicmd 'K' history-substring-search-up
bindkey -M vicmd 'J' history-substring-search-down
bindkey '^\' accept-and-hold
}

12
.zsh/fzf.zsh Normal file

@ -0,0 +1,12 @@
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude 'node_modules' --exclude 'nix/profiles' ."
# export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_CTRL_T_COMMAND="fd --follow --full-path --hidden --base-directory . --exclude '.git' --exclude 'node_modules' --exclude 'nix/profiles' ."
export FZF_ALT_C_COMMAND="fd -H -t d ."
export DISABLE_FZF_AUTO_COMPLETION="true"
# Options to fzf command
export FZF_COMPLETION_OPTS='+c -x'
export FZF_DEFAULT_OPTS="--height=60% --inline-info --bind=ctrl-j:preview-half-page-down,ctrl-k:preview-half-page-up --color=fg:#f8f8f2,bg:#282a36,hl:#bd93f9 --color=fg+:#f8f8f2,bg+:#44475a,hl+:#bd93f9 --color=info:#ffb86c,prompt:#50fa7b,pointer:#ff79c6 --color=marker:#ff79c6,spinner:#ffb86c,header:#6272a4"
# Using highlight (http://www.andre-simon.de/doku/highlight/en/highlight.html)
# export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
export FZF_CTRL_T_OPTS="--preview 'bat --style=numbers --color=always --line-range :200 {}'"

17
.zsh/zvm.zsh Normal file

@ -0,0 +1,17 @@
# if [[ "$(hostnamectl hostname)" == "sth" ]]; then
# if [[ "$(hostname -s)" == "sth" ]]; then
if [[ "$(lsb_release -i -s)" == "Arch" ]]; then
local fzf_bindings="/usr/share/fzf/key-bindings.zsh"
elif [[ "$(lsb_release -i -s)" == "Fedora" ]]; then
local fzf_bindings="/usr/share/fzf/shell/key-bindings.zsh"
fi
zvm_after_init_commands+=("[ -f $fzf_bindings ] && source $fzf_bindings")
unset fzf_bindings
function zvm_config() {
ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT
ZVM_CURSOR_STYLE_ENABLED=false
# ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BLOCK
}

46
.zshrc

@ -110,52 +110,14 @@
ZSH_THEME_GIT_PROMPT_CACHE=" " ZSH_THEME_GIT_PROMPT_CACHE=" "
# map Del escape sequence to actual Del key in all (n,i) modes to resemble vim instead of vi
bindkey -a '^[[3~' delete-char
# map arrow up/down to control fish-like history substring search and highlighting
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey '^o' fzf-open
# also map the same keys in 'viins' (INSERT) mode...
bindkey -M viins '^[[A' history-substring-search-up
bindkey -M viins '^[[B' history-substring-search-down
bindkey -M viins '^o' fzf-open
# ...and in 'vicmd' (NORMAL) mode...
bindkey -M vicmd '^[[A' history-substring-search-up
bindkey -M vicmd '^[[B' history-substring-search-down
# ...and as well to K, J, instead of arrow up/down, respectively.
# note these are capital letters, original behaviour of j, k is left unchanged
bindkey -M vicmd 'K' history-substring-search-up
bindkey -M vicmd 'J' history-substring-search-down
bindkey '^\' accept-and-hold
HISTORY_SUBSTRING_SEARCH_FUZZY=" " HISTORY_SUBSTRING_SEARCH_FUZZY=" "
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude 'node_modules' --exclude 'nix/profiles' ."
# export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_CTRL_T_COMMAND="fd --follow --full-path --hidden --base-directory . --exclude '.git' --exclude 'node_modules' --exclude 'nix/profiles' ."
export FZF_ALT_C_COMMAND="fd -H -t d ."
export DISABLE_FZF_AUTO_COMPLETION="true"
# Options to fzf command
export FZF_COMPLETION_OPTS='+c -x'
export FZF_DEFAULT_OPTS="--height=60% --inline-info --bind=ctrl-j:preview-half-page-down,ctrl-k:preview-half-page-up --color=fg:#f8f8f2,bg:#282a36,hl:#bd93f9 --color=fg+:#f8f8f2,bg+:#44475a,hl+:#bd93f9 --color=info:#ffb86c,prompt:#50fa7b,pointer:#ff79c6 --color=marker:#ff79c6,spinner:#ffb86c,header:#6272a4"
# Using highlight (http://www.andre-simon.de/doku/highlight/en/highlight.html)
# export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
export FZF_CTRL_T_OPTS="--preview 'bat --style=numbers --color=always --line-range :200 {}'"
# if [[ "$(hostnamectl hostname)" == "sth" ]]; then
# if [[ "$(hostname -s)" == "sth" ]]; then
if [[ "$(lsb_release -i -s)" == "Arch" ]]; then
local fzf_bindings="/usr/share/fzf/key-bindings.zsh"
elif [[ "$(lsb_release -i -s)" == "Fedora" ]]; then
local fzf_bindings="/usr/share/fzf/shell/key-bindings.zsh"
fi
zvm_after_init_commands+=("[ -f $fzf_bindings ] && source $fzf_bindings")
unset fzf_bindings
# ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BLOCK
local __tosrc=( local __tosrc=(
~/.zsh/bindings.zsh
~/.zsh/fzf.zsh
~/.zsh/zvm.zsh
~/.dotenv ~/.dotenv
${XDG_RUNTIME_DIR}/secrets/envs ${XDG_RUNTIME_DIR}/secrets/envs
~/.zsh/aliases.zsh ~/.zsh/aliases.zsh