mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
feat: add sane delete-backwards
This commit is contained in:
parent
ea4e48aa2a
commit
875083a74e
2 changed files with 155 additions and 90 deletions
|
|
@ -8755,7 +8755,8 @@ Here we set some aliases (some of them should be shellApplications instead) as w
|
|||
{
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
shellAliases = lib.recursiveUpdate {
|
||||
shellAliases = lib.recursiveUpdate
|
||||
{
|
||||
hg = "history | grep";
|
||||
hmswitch = "cd ~/.dotfiles; home-manager --flake .#$(whoami)@$(hostname) switch; cd -;";
|
||||
nswitch = "cd ~/.dotfiles; sudo nixos-rebuild --flake .#$(hostname) switch; cd -;";
|
||||
|
|
@ -8806,6 +8807,38 @@ Here we set some aliases (some of them should be shellApplications instead) as w
|
|||
bindkey "^[[1;5D" backward-word
|
||||
bindkey "^[[1;5C" forward-word
|
||||
|
||||
my-backward-delete-word() {
|
||||
# Copy the global WORDCHARS variable to a local variable. That way any
|
||||
# modifications are scoped to this function only
|
||||
local WORDCHARS=$WORDCHARS
|
||||
# Use bash string manipulation to remove `:` so our delete will stop at it
|
||||
WORDCHARS="''${WORDCHARS//:}"
|
||||
# Use bash string manipulation to remove `/` so our delete will stop at it
|
||||
WORDCHARS="''${WORDCHARS//\/}"
|
||||
# Use bash string manipulation to remove `.` so our delete will stop at it
|
||||
WORDCHARS="''${WORDCHARS//.}"
|
||||
# zle <widget-name> will run an existing widget.
|
||||
zle backward-delete-word
|
||||
}
|
||||
zle -N my-backward-delete-word
|
||||
bindkey '^H' my-backward-delete-word
|
||||
|
||||
# This will be our `ctrl+alt+w` command
|
||||
my-backward-delete-whole-word() {
|
||||
# Copy the global WORDCHARS variable to a local variable. That way any
|
||||
# modifications are scoped to this function only
|
||||
local WORDCHARS=$WORDCHARS
|
||||
# Use bash string manipulation to add `:` to WORDCHARS if it's not present
|
||||
# already.
|
||||
[[ ! $WORDCHARS == *":"* ]] && WORDCHARS="$WORDCHARS"":"
|
||||
# zle <widget-name> will run that widget.
|
||||
zle backward-delete-word
|
||||
}
|
||||
# `zle -N` will create a new widget that we can use on the command line
|
||||
zle -N my-backward-delete-whole-word
|
||||
# bind this new widget to `ctrl+alt+w`
|
||||
bindkey '^W' my-backward-delete-whole-word
|
||||
|
||||
vterm_printf() {
|
||||
if [ -n "$TMUX" ] && ([ "''${TERM%%-*}" = "tmux" ] || [ "''${TERM%%-*}" = "screen" ]); then
|
||||
# Tell tmux to pass the escape sequences through
|
||||
|
|
|
|||
|
|
@ -54,6 +54,38 @@
|
|||
bindkey "^[[1;5D" backward-word
|
||||
bindkey "^[[1;5C" forward-word
|
||||
|
||||
my-backward-delete-word() {
|
||||
# Copy the global WORDCHARS variable to a local variable. That way any
|
||||
# modifications are scoped to this function only
|
||||
local WORDCHARS=$WORDCHARS
|
||||
# Use bash string manipulation to remove `:` so our delete will stop at it
|
||||
WORDCHARS="''${WORDCHARS//:}"
|
||||
# Use bash string manipulation to remove `/` so our delete will stop at it
|
||||
WORDCHARS="''${WORDCHARS//\/}"
|
||||
# Use bash string manipulation to remove `.` so our delete will stop at it
|
||||
WORDCHARS="''${WORDCHARS//.}"
|
||||
# zle <widget-name> will run an existing widget.
|
||||
zle backward-delete-word
|
||||
}
|
||||
zle -N my-backward-delete-word
|
||||
bindkey '^H' my-backward-delete-word
|
||||
|
||||
# This will be our `ctrl+alt+w` command
|
||||
my-backward-delete-whole-word() {
|
||||
# Copy the global WORDCHARS variable to a local variable. That way any
|
||||
# modifications are scoped to this function only
|
||||
local WORDCHARS=$WORDCHARS
|
||||
# Use bash string manipulation to add `:` to WORDCHARS if it's not present
|
||||
# already.
|
||||
[[ ! $WORDCHARS == *":"* ]] && WORDCHARS="$WORDCHARS"":"
|
||||
# zle <widget-name> will run that widget.
|
||||
zle backward-delete-word
|
||||
}
|
||||
# `zle -N` will create a new widget that we can use on the command line
|
||||
zle -N my-backward-delete-whole-word
|
||||
# bind this new widget to `ctrl+alt+w`
|
||||
bindkey '^W' my-backward-delete-whole-word
|
||||
|
||||
vterm_printf() {
|
||||
if [ -n "$TMUX" ] && ([ "''${TERM%%-*}" = "tmux" ] || [ "''${TERM%%-*}" = "screen" ]); then
|
||||
# Tell tmux to pass the escape sequences through
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue