feat: improve zsh

This commit is contained in:
Leon Schwarzäugl 2025-04-16 11:02:06 +02:00
parent e8c405b3f1
commit cf9349168f
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
2 changed files with 41 additions and 47 deletions

View file

@ -9791,7 +9791,7 @@ The theme is handled by stylix.
zsh is the most convenient shell for me and it happens to be super neat to configure within home manager. zsh is the most convenient shell for me and it happens to be super neat to configure within home manager.
Here we set some aliases (some of them should be shellApplications instead) as well as some zsh plugins like =fzf-tab=. Here we set some aliases (some of them should be shellApplications instead) as well as some zsh plugins like =fzf-tab=.
Concerning the shell extensions, =zle <widget-name>= will run an existing widget and =zle -N <function_name>= will make a function available for use. The =my-= functions all remove =.= =/= and =:= from the =WORDCHARS= so that functions will stop there. Concerning the shell extensions, =zle <widget-name>= will run an existing widget and =zle -N <function_name>= will make a function available for use. The =my-= functions all remove =.= =/= and =:= from the =WORDCHARS= so that functions will stop there. The keycodes can be found using =showkeys -a=
#+begin_src nix :tangle modules/home/common/zsh.nix #+begin_src nix :tangle modules/home/common/zsh.nix
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
@ -9854,8 +9854,8 @@ Concerning the shell extensions, =zle <widget-name>= will run an existing widget
history = { history = {
expireDuplicatesFirst = true; expireDuplicatesFirst = true;
path = "$HOME/.histfile"; path = "$HOME/.histfile";
save = 10000; save = 100000;
size = 10000; size = 100000;
}; };
historySubstringSearch = { historySubstringSearch = {
enable = true; enable = true;
@ -9870,47 +9870,44 @@ Concerning the shell extensions, =zle <widget-name>= will run an existing widget
]; ];
initExtra = '' initExtra = ''
my-forward-word() { my-forward-word() {
local WORDCHARS=$WORDCHARS local WORDCHARS=$WORDCHARS
WORDCHARS="''${WORDCHARS//:}" WORDCHARS="''${WORDCHARS//:}"
WORDCHARS="''${WORDCHARS//\/}" WORDCHARS="''${WORDCHARS//\/}"
WORDCHARS="''${WORDCHARS//.}" WORDCHARS="''${WORDCHARS//.}"
zle backward-word zle forward-word
} }
zle -N my-forward-word zle -N my-forward-word
# ctrl + right # ctrl + right
bindkey "^[[1;5C" my-forward-word bindkey "^[[1;5C" my-forward-word
# shift + right # shift + right
bindkey "^[[1;2D" forward-word bindkey "^[[1;2C" forward-word
my-backward-word() { my-backward-word() {
local WORDCHARS=$WORDCHARS local WORDCHARS=$WORDCHARS
WORDCHARS="''${WORDCHARS//:}" WORDCHARS="''${WORDCHARS//:}"
WORDCHARS="''${WORDCHARS//\/}" WORDCHARS="''${WORDCHARS//\/}"
WORDCHARS="''${WORDCHARS//.}" WORDCHARS="''${WORDCHARS//.}"
zle forward-word zle backward-word
} }
zle -N my-backward-word zle -N my-backward-word
# ctrl + left # ctrl + left
bindkey "^[[1;5D" -mybackward-word bindkey "^[[1;5D" my-backward-word
# shift + left # shift + left
bindkey "^[[1;2C" backward-word bindkey "^[[1;2D" backward-word
my-backward-delete-word() { my-backward-delete-word() {
local WORDCHARS=$WORDCHARS local WORDCHARS=$WORDCHARS
WORDCHARS="''${WORDCHARS//:}" WORDCHARS="''${WORDCHARS//:}"
WORDCHARS="''${WORDCHARS//\/}" WORDCHARS="''${WORDCHARS//\/}"
WORDCHARS="''${WORDCHARS//.}" WORDCHARS="''${WORDCHARS//.}"
zle backward-delete-word zle backward-delete-word
} }
zle -N my-backward-delete-word zle -N my-backward-delete-word
# ctrl + del # ctrl + del
bindkey '^H' my-backward-delete-word bindkey '^H' my-backward-delete-word
# shift + del
bindkey '^?' backward-delete-word
''; '';
}; };
}; };

View file

@ -58,8 +58,8 @@ in
history = { history = {
expireDuplicatesFirst = true; expireDuplicatesFirst = true;
path = "$HOME/.histfile"; path = "$HOME/.histfile";
save = 10000; save = 100000;
size = 10000; size = 100000;
}; };
historySubstringSearch = { historySubstringSearch = {
enable = true; enable = true;
@ -74,47 +74,44 @@ in
]; ];
initExtra = '' initExtra = ''
my-forward-word() { my-forward-word() {
local WORDCHARS=$WORDCHARS local WORDCHARS=$WORDCHARS
WORDCHARS="''${WORDCHARS//:}" WORDCHARS="''${WORDCHARS//:}"
WORDCHARS="''${WORDCHARS//\/}" WORDCHARS="''${WORDCHARS//\/}"
WORDCHARS="''${WORDCHARS//.}" WORDCHARS="''${WORDCHARS//.}"
zle backward-word zle forward-word
} }
zle -N my-forward-word zle -N my-forward-word
# ctrl + right # ctrl + right
bindkey "^[[1;5C" my-forward-word bindkey "^[[1;5C" my-forward-word
# shift + right # shift + right
bindkey "^[[1;2D" forward-word bindkey "^[[1;2C" forward-word
my-backward-word() { my-backward-word() {
local WORDCHARS=$WORDCHARS local WORDCHARS=$WORDCHARS
WORDCHARS="''${WORDCHARS//:}" WORDCHARS="''${WORDCHARS//:}"
WORDCHARS="''${WORDCHARS//\/}" WORDCHARS="''${WORDCHARS//\/}"
WORDCHARS="''${WORDCHARS//.}" WORDCHARS="''${WORDCHARS//.}"
zle forward-word zle backward-word
} }
zle -N my-backward-word zle -N my-backward-word
# ctrl + left # ctrl + left
bindkey "^[[1;5D" -mybackward-word bindkey "^[[1;5D" my-backward-word
# shift + left # shift + left
bindkey "^[[1;2C" backward-word bindkey "^[[1;2D" backward-word
my-backward-delete-word() { my-backward-delete-word() {
local WORDCHARS=$WORDCHARS local WORDCHARS=$WORDCHARS
WORDCHARS="''${WORDCHARS//:}" WORDCHARS="''${WORDCHARS//:}"
WORDCHARS="''${WORDCHARS//\/}" WORDCHARS="''${WORDCHARS//\/}"
WORDCHARS="''${WORDCHARS//.}" WORDCHARS="''${WORDCHARS//.}"
zle backward-delete-word zle backward-delete-word
} }
zle -N my-backward-delete-word zle -N my-backward-delete-word
# ctrl + del # ctrl + del
bindkey '^H' my-backward-delete-word bindkey '^H' my-backward-delete-word
# shift + del
bindkey '^?' backward-delete-word
''; '';
}; };
}; };