diff --git a/glasshouse-desktop/home/zsh/zkbd b/glasshouse-desktop/home/zsh/zkbd new file mode 100644 index 0000000..1e5ce39 --- /dev/null +++ b/glasshouse-desktop/home/zsh/zkbd @@ -0,0 +1,36 @@ + +function left-beep { + [[ $CURSOR -eq 0 ]] && return + zle vi-backward-char + (aplay /home/pagedmov/sound/sys/move_h.wav > /dev/null 2>&1 &) +} +function right-beep { + zle autosuggest-accept + [[ $CURSOR -eq ${#BUFFER} ]] && return + zle vi-forward-char + (aplay /home/pagedmov/sound/sys/move_h.wav > /dev/null 2>&1 &) +} +function up-beep { + zle up-line-or-history + (aplay /home/pagedmov/sound/sys/move_v.wav > /dev/null 2>&1 &) +} +function down-beep { + zle down-line-or-history + (aplay /home/pagedmov/sound/sys/move_v.wav > /dev/null 2>&1 &) +} +zle -N left-beep +zle -N right-beep +zle -N up-beep +zle -N down-beep + +bindkey -M viins "^[OD" left-beep +bindkey -M viins "^[OC" right-beep +bindkey -M viins "^[OB" down-beep +bindkey -M viins "^[OA" up-beep + +bindkey -M vicmd "h" left-beep +bindkey -M vicmd "l" right-beep +bindkey -M vicmd "j" down-beep +bindkey -M vicmd "k" up-beep + +ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=("right-beep") diff --git a/glasshouse-desktop/home/zsh/zsh-style b/glasshouse-desktop/home/zsh/zsh-style new file mode 100644 index 0000000..3642d6a --- /dev/null +++ b/glasshouse-desktop/home/zsh/zsh-style @@ -0,0 +1,68 @@ +# set the terminal mode when entering or exiting zle, otherwise terminfo keys are not loaded +if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then + zle-line-init() { echoti smkx; }; zle -N zle-line-init + zle-line-finish() { echoti rmkx; }; zle -N zle-line-finish +fi + +# History +zshAddHistory() { + whence ${${(z)1}[1]} >| /dev/null || return 1 +} + +# ---| Correction and Autocompletion |--- # +zstyle ':completion:*:correct:*' original true +zstyle ':completion:*:correct:*' insert-unambiguous true +zstyle ':completion:*:approximate:*' max-errors 'reply=($(( ($#PREFIX + $#SUFFIX) / 3 )) numeric)' + +# completion +zstyle ':completion:*' use-cache on +zstyle ':completion:*' cache-path "$comppath" +zstyle ':completion:*' rehash true +zstyle ':completion:*' verbose true +zstyle ':completion:*' insert-tab false +zstyle ':completion:*' accept-exact '*(N)' +zstyle ':completion:*' squeeze-slashes true +zstyle ':completion:*:*:*:*:*' menu select +zstyle ':completion:*:match:*' original only +zstyle ':completion:*:-command-:*:' verbose false +zstyle ':completion::complete:*' gain-privileges 1 +zstyle ':completion:*:manuals.*' insert-sections true +zstyle ':completion:*:manuals' separate-sections true +zstyle ':completion:*' completer _complete _match _approximate _ignored +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' +zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories + +# labels and categories +zstyle ':completion:*' group-name '' +zstyle ':completion:*:matches' group 'yes' +zstyle ':completion:*:options' description 'yes' +zstyle ':completion:*:options' auto-description '%d' +zstyle ':completion:*:default' list-prompt '%S%M matches%s' +zstyle ':completion:*' format ' %F{green}->%F{yellow} %d%f' +zstyle ':completion:*:messages' format ' %F{green}->%F{purple} %d%f' +zstyle ':completion:*:descriptions' format ' %F{green}->%F{yellow} %d%f' +zstyle ':completion:*:warnings' format ' %F{green}->%F{red} no matches%f' +zstyle ':completion:*:corrections' format ' %F{green}->%F{green} %d: %e%f' + +# menu colours +eval "$(dircolors)" +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=36=0=01' + +# command parameters +zstyle ':completion:*:functions' ignored-patterns '(prompt*|_*|*precmd*|*preexec*)' +zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-} +zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" +zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o command | uniq' +zstyle ':completion:*:(vim|nvim|vi|nano):*' ignored-patterns '*.(wav|mp3|flac|ogg|mp4|avi|mkv|iso|so|o|7z|zip|tar|gz|bz2|rar|deb|pkg|gzip|pdf|png|jpeg|jpg|gif)' + +# hostnames and addresses +zstyle ':completion:*:ssh:*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' +zstyle ':completion:*:ssh:*' group-order users hosts-domain hosts-host users hosts-ipaddr +zstyle ':completion:*:(scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' +zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr +zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost +zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*' +zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*' +zstyle -e ':completion:*:hosts' hosts 'reply=( ${=${=${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*} ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}})' +ttyctl -f diff --git a/glasshouse-desktop/home/zshell.nix b/glasshouse-desktop/home/zsh/zshell.nix similarity index 98% rename from glasshouse-desktop/home/zshell.nix rename to glasshouse-desktop/home/zsh/zshell.nix index 4b19a29..4e0df78 100644 --- a/glasshouse-desktop/home/zshell.nix +++ b/glasshouse-desktop/home/zsh/zshell.nix @@ -260,7 +260,7 @@ invoke() { nix run nixpkgs#"$@" } ''; initExtraBeforeCompInit = '' - source ~/.zstyle + source ~/sysflakes/glasshouse-desktop/home/zsh/zsh-style ''; initExtra = '' if [ ! -e $HOME/.zsh_history ]; then @@ -307,7 +307,7 @@ if [ "$TERM" = "linux" ] ; then fi clear -source ~/.zkbd +source ~/sysflakes/glasshouse-desktop/home/zsh/.zkbd ~/coding/scripts/splash.sh eval "$(starship init zsh)" s_check && (aplay ~/sound/sys/sh-source.wav > /dev/null 2>&1 &)