I am desperately seaching for a way to enable classic navigation and selection in zsh shell.. Meaning, I want to be able to: - select char by char in zsh using shift+left/right - move word by word in zsh using control+left/right - select word by word in zsh using ctrl+shift+left/right
I have been able, using a few stupid hacks and solutions I found on different related topics, to do the 2 first points of my list, but I cannot get a simple solution to make my 3rd point work properly... Does anyone have an idea on how to do this? I am using gnome-terminal, but I don't mind switching to an other one if it is needed to do what I want, as long as the new one allows me to copy/paste/scroll using the mouse.
I hope you have a solution to my problem =)
Ok this is what I currently have, in my .zshrc, to control the keybinding:
function zle-line-init {
marking=0
}
zle -N zle-line-init
function select-char-right {
if (( $marking != 1 ))
then
marking=1
zle set-mark-command
fi
zle .forward-char
}
zle -N select-char-right
function select-char-left {
if (( $marking != 1 ))
then
marking=1
zle set-mark-command
fi
zle .backward-char
}
zle -N select-char-left
function forward-char {
if (( $marking == 1 ))
then
marking=0
NUMERIC=-1 zle set-mark-command
fi
zle .forward-char
}
zle -N forward-char
function backward-char {
if (( $marking == 1 ))
then
marking=0
NUMERIC=-1 zle set-mark-command
fi
zle .backward-char
}
zle -N backward-char
function delete-char {
if (( $marking == 1 ))
then
zle kill-region
marking=0
else
zle .delete-char
fi
}
zle -N delete-char
bindkey ';6D' select-word-left ## not working yet
bindkey ';6C' select-word-right ## not working yet
bindkey ';2D' select-char-left # assuming xterm
bindkey ';2C' select-char-right # assuming xterm
bindkey ';5D' backward-word
bindkey ';5C' forward-word
bindkey '^[[3~' delete-char
with this, I can:
move word by word with control
select a region to delete with shift (only problem, I have no visual on the marked region)
a delete key that works
Sorry for the confusion, I am currently on xterm terminal (just changed my desktop environment to xfce4)
I would still like to mark a region to kill using ctrl+shift+arrows, haven't been able to do this yet because I don't know how to get the number of chars moved with forward/backward-word.. In a better world, I would also like to have an highlighted marked region... =) Any idea?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With