Questions tagged [zle]

46 questions
24
votes
3 answers

How to configure Ctrl+w as delete word in zsh

I want to delete a word by Ctrl+W in zsh like. vim /foo/bar^W vim /foo/ And found a solution for bash, but bind is not in zsh function. Is it possible to configure ctrl-w (delete word)? How can I configure Ctrl+W as a delete-word?
ironsand
  • 5,085
  • 12
  • 50
  • 73
12
votes
2 answers

Bindkey to execute command (Zsh)

In bash one can do the following: bind -x '"\C-l":ls' to map Ctrl+L to external (ie. system's rather than readline function) ls command to list directory contents. How to do the same in zsh, and preferably with Alt (\M-l?) instead of Ctrl as it is…
user86041
8
votes
1 answer

Backspace in zsh stuck

In set -o vi mode in bash, when I press Esc+k to get the last entered command, and then A, I end up in the insert mode, which allows me to press backspace to start deleting the end of the last command. With zsh in set -o vi mode, everything works up…
Petr Skocik
  • 28,176
  • 14
  • 81
  • 141
7
votes
1 answer

How can I get back into "normal" edit-mode after pressing esc in zsh (vi mode)?

I'm using zsh in vi-mode. When I go to normal mode with ESC and then back into insert mode (for example using i, a or s), the line editor kind of "protects" the part of the line in front of the char, at which I was when re-entering insert mode. I…
groxxda
  • 1,028
  • 1
  • 7
  • 11
7
votes
1 answer

How can I configure ZSH's vi mode to persist the state between commands?

I am aware how to set ZSH's default line editor to use vi-like keybindings... bindkeys -v ...and even to default each new prompt to be in command mode instead of insert mod by default... zle-line-init() { zle -K vicmd; } zle -N…
Caleb
  • 69,278
  • 18
  • 196
  • 226
6
votes
2 answers

How to bind a keyboard shortcut in zsh to a program requiring stdin?

This is a follow-up to this question: I'm trying to create a keyboard shortcut for the terminal file manager ranger, in order to jump from the zsh prompt into the file manager with a single keystroke. I was following the linked answer, adding this…
bluenote10
  • 291
  • 1
  • 7
6
votes
1 answer

ZLE: Key bindings codes list

I know that in bindkey '\ep' autosuggest-accept-suggested-small-word the \e refers to the ⎇ Alt key. I also know that C- refers to the ⎈ Ctrl key. Is there a list referencing all the keys because I have the hardest time to understand how ZLE works…
politicus
  • 175
  • 1
  • 8
6
votes
1 answer

How can I find the zsh function associated with a zle widget?

I'm messing around with the accept-line widget and not getting the results I want. I want to inspect (and log) what is happening to accept-line by finding the underlying zsh function. My understanding is that zle widgets exist in their own separate…
Att Righ
  • 1,176
  • 11
  • 29
6
votes
5 answers

Move to the previous line of a multi-line command

When editing multi-line commands, with escaped newlines, I cannot move up lines. For example, suppose I enter echo \ one one line, then I press Enter, and then I want to edit the echo \ part of the command. Pressing Up doesn't move back to the first…
Leandros
  • 712
  • 2
  • 7
  • 16
5
votes
2 answers

zsh history-beginning-search-backwards doesn't position cursor as desired

In bash, I used this: % cat .inputrc "\e[A": history-search-backward "\e[B": history-search-forward I'd like the same behavior in .zsh, so I've tried these bindkeys: "^[[A" history-beginning-search-backward "^[[B"…
mayostard
  • 51
  • 2
5
votes
5 answers

How to repeat currently typed in parameter in zsh?

Sometimes we just need to type a slightly different name when using mv/cp/convert. For example, convert IMG-long-number.jpg IMG-long-number.png How can I repeat IMG-long-number.jpg before typing the IMG-long-number.png, so I only need to make…
xuhdev
  • 327
  • 3
  • 15
4
votes
2 answers

Alt + . (dot) shows &, instead of a previous argument

I (ab)use Alt + . to recover the last argument in a previous command (I'm using ZSH): for example, $ convert img.png img.pdf $ llpp (alt + .) # which produces llpp img.pdf but sometimes I review a pdf with llpp $ llpp pdffile.pdf& and then if I…
David
  • 167
  • 1
  • 6
4
votes
4 answers

Zsh refer to last element of current argument list and expand it

Suppose I do something like: ln a_file_with_a_long_filename.pdf ~/path/to/a/new/hardlink/a_file_with_a_long_filename_slightly_modified.pdf Is there a way to refer to and expand a_file_with_a_long_filename.pdf if my cursor is at the end of the…
student
  • 17,875
  • 31
  • 103
  • 169
4
votes
1 answer

Zsh clear command line from zsh/sched call

I try the following: clear-cmdline() { zle && zle kill-buffer sched +3 clear-cmdline } sched +3 clear-cmdline After I run this code, I enter a few letters at prompt, and wait. Nothing happens. Unless I continue typing, then the command line…
Itzie
  • 139
  • 1
  • 1
  • 4
4
votes
1 answer

How can you get the current terminal line (the one that is still editable by the user)?

I need a way to use the current line which the users typed into as variable for a shell function. my current code, which can be called by ctrl+r zle -N search bindkey "^R" search search () { read str; fc -ln -30 | grep $(printf "%q\n"…
1
2 3 4