Questions tagged [zle]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
29 views

Is it possible to delete a word in the forward direction with zsh?

I found that I was able to implement Ctrl+Delete in bash using "^[[3;5~": shell-kill-word inside my ~/.inputrc.  However, zsh does not use inputrc, and ZLE has no shell-kill-word option that ...
3
votes
1answer
35 views

Make one normal mode command while in insert mode in zsh's vi mode

Zsh vi mode doesn't have ctrl-o behavior set by default how do I get to work like in vim ?
2
votes
1answer
130 views

Using fzf in a zle key binding

I have the following function in my .zshrc function foo() { filename="$(fzf)" } zle -N foo bindkey '^X' foo now if I call foo by typing it, it works as expected, but if I call it via ...
0
votes
1answer
37 views

How to bind _list_expansions in Zsh Line Editor

I'm trying to bind "possible completions" (currently bound to C-d) to the key M-= in Zsh. The code, therefore, should be: bindkey "\e=" _list_expansions but it has no effect!? Do you understand ...
1
vote
1answer
75 views

zsh: PageUp in menu completion

In my .zshrc I have zstyle ':completion:*' menu select=20 This way when I hit Tab twice, I receive a menu of completions (assuming there are at least 20 to choose from). I can then navigate it ...
0
votes
1answer
138 views

What is the difference between `set -o` vs `bindkey`?

From what I have seen, both set -o emacs and bindkey -e are used to modify the behavior of your terminal line editor to emulate emacs whereas set -o vi and bindkey -v are used to emulate vi ...
1
vote
1answer
72 views

How to cancel selection mode in zsh in other way than add text to $BUFFER?

zle widgets working by Ctrl-Right keys, Ctrl-Left keys (first widget is starting selection mode): c-sel-r-reg () { local WORDCHARS=${WORDCHARS/\/} zle select-in-word } zle -N c-sel-r-reg bindkey "...
1
vote
1answer
30 views

Get if command is multiline in a ZLE widget

How can I get whether the command being typed is multiline? $CONTEXT can determine when at a secondary prompt like: $ echo 'hello quote> world' But how can I determine when there's a newline ...
2
votes
1answer
737 views

Setting new key bindings in ZSH removes default ones

I've added following code at the end of my .zshrc: export VISUAL=vim autoload edit-command-line; zle -N edit-command-line bindkey -M vicmd v edit-command-line When I restart the shell, it works ...
1
vote
0answers
30 views

Is there any way to change $? from a zle widget?

I have a widget for mapping ^Z to fg: function ctrlz() { [[ $(jobs | wc -l) > 0 ]] && { zle -I fg } } However, since widgets can't change $?, the exit status of ...
3
votes
2answers
1k views

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 ...
2
votes
1answer
124 views

zsh: populate search input with existing line contents when ^R is pressed?

Given .zshrc config: bindkey -v bindkey "^R" history-incremental-pattern-search-backward When I type foo<^R>bar at an empty prompt, it searches for the most recent command matching bar. How ...
4
votes
4answers
479 views

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 ...
3
votes
1answer
539 views

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. ...
0
votes
0answers
158 views

Avoid terminal scroll issue when using zle reset-prompt

I use TMOUT=10 - 10s to update time in prompt so it caused scroll always go back to current prompt. For i.e: If I scroll back serverl pages of output then 10s later, zsh scroll down when prompt was ...
1
vote
1answer
73 views

Entering . (dot) cancels zsh incremental history search

History Search Ctrl+R in my zsh cancels if I enter the dot . character. If I hit Ctrl+R the bck-i-search: prompt appears and the history is searched according to the words I enter. But as soon as I ...
1
vote
2answers
1k views

Using putty, Left and Right keys move cursor one word, instead of one char

I have looked for a solution to this OhMyZSH! problem for a few days now, but can't find a solution. Admittedly, I do not understand how zle really works, same for bindkey. Same goes for the way ...
6
votes
1answer
3k views

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 ...
0
votes
2answers
483 views

Why isn't zsh autocomplete using history behaving consistently from login to login?

After adding the following lines to my .zshrc: autoload -U up-line-or-beginning-search autoload -U down-line-or-beginning-search zle -N up-line-or-beginning-search zle -N down-line-or-beginning-...
2
votes
1answer
1k views

zsh: Where is the `key` -> `terminfo` dictionary defined

I'm learning zsh at the moment, and configuring my ~/.zshrc. On the Archwiki, I found a snippet to change the history searching behavior: autoload -Uz up-line-or-beginning-search down-line-or-...
3
votes
1answer
179 views

How to repeat a zle widget an arbitrary number of times when the completion menu is open?

I'm using the zsh shell, and I'm trying to install a few key bindings to use keys similar to the ones I would use in a Vim buffer, when a completion menu is open. So, inside the menuselect keymap I'...
9
votes
2answers
3k views

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 ...
6
votes
1answer
503 views

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 ...
5
votes
5answers
764 views

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 ...
3
votes
1answer
671 views

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. ...
5
votes
1answer
2k views

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....
3
votes
1answer
176 views

Write warning while typing in zsh prompt

I know that it is possible to display text "outside" of the zsh prompt where you are typing. Common example is completions: myhost Wed 8 10:06 ~/sandlot $ e .py█ Press Tab, et voilá: myhost Wed 8 ...
1
vote
2answers
466 views

zle read first word in line?

Let us say: % ls ./ _ when foo is called, where _ is the cursor position. foo(){ echo $COMMAND } zle -N foo How can COMMAND be set such that foo will write out the 'command' (as in, the first ...
5
votes
4answers
4k views

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 ...
2
votes
1answer
366 views

Why are some ZLE sequences being remapped to “self-insert”?

I've been tinkering with my dotfiles lately, and at some point I lost use of the default ^A and ^K keymappings, which I use frequently. bindkey -L | grep '\^[AK] # bindkey -R "^A"-"^C" self-insert # ...
20
votes
3answers
4k views

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 ...
3
votes
1answer
373 views

Why does select-word-style stop me from using backward-kill-word for leading whitespace?

If I have just some whitespace at be beginning of my zsh prompt, I can usually ^W (backward-kill-word) it away. However, as soon as I load select-word-style - even if I don't select any special style -...
1
vote
1answer
670 views

Key to comment out the current line and keep editing it in zsh

On Bash I was using ESC # after Ctrl+R to prefix a # to the found line and keep it in the terminal, something similar for zsh?
4
votes
1answer
829 views

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 ...
7
votes
1answer
264 views

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, ...
7
votes
1answer
1k views

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-...