Questions tagged [zle]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
2 answers
98 views

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&...
user avatar
2 votes
1 answer
93 views

What is the "global keymap" in zsh?

In the zsh manual 18.2.2 Local Keymaps it refers to the "global keymap" thrice. Where is this term defined? How do I find out what is my current global keymap, and how would I change it?
user avatar
  • 24.6k
2 votes
2 answers
119 views

How to use `Alt + .` in zsh with Vim bindings

I am using zsh with bindkeys -v. Alt + . does not work as expected. It seems to repeat what is currently typed in stdin, but not entered, on the next line. This post seems to imply it does work as it ...
user avatar
2 votes
2 answers
52 views

zsh keybindings: make backward-kill-word act on whole quoted string

When using Ctrl+w or Alt+Backspace or Alt+d keyboard shortcuts to delete words backward/forward, I know I can define the WORDCHARS characters: WORDCHARS='~!#$%^&*(){}[]<>?.+;-' for example, ...
user avatar
0 votes
0 answers
45 views

How to execute bindkey shortcut in same TTY?

My goal is to create a notifier function in zsh that tells me when a current command has finished running. The function is basically running and implemented but there is still one bug that I want to ...
user avatar
  • 163
1 vote
1 answer
131 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 ...
user avatar
  • 1,919
3 votes
1 answer
91 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 ?
user avatar
2 votes
1 answer
320 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 ...
user avatar
  • 347
0 votes
1 answer
44 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 ...
user avatar
1 vote
1 answer
145 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 ...
user avatar
0 votes
1 answer
367 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 ...
user avatar
1 vote
1 answer
150 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 "...
user avatar
  • 61
1 vote
1 answer
45 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 ...
user avatar
  • 187
2 votes
1 answer
2k 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 ...
user avatar
  • 123
1 vote
0 answers
41 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 ...
user avatar
  • 213
4 votes
2 answers
2k 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 ...
user avatar
  • 167
2 votes
1 answer
134 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 ...
user avatar
  • 123
4 votes
4 answers
562 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 ...
user avatar
  • 16.7k
5 votes
1 answer
799 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. ...
user avatar
0 votes
0 answers
179 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 ...
user avatar
  • 1,635
1 vote
1 answer
87 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 ...
user avatar
  • 113
1 vote
2 answers
2k 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 ...
user avatar
  • 113
6 votes
1 answer
4k 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 ...
user avatar
  • 175
0 votes
2 answers
552 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-...
user avatar
  • 319
3 votes
1 answer
2k 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-...
user avatar
  • 155
3 votes
1 answer
238 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'...
user avatar
10 votes
2 answers
4k 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 ...
user avatar
6 votes
1 answer
779 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 ...
user avatar
  • 1,046
5 votes
5 answers
919 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 ...
user avatar
  • 307
3 votes
1 answer
836 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. ...
user avatar
  • 119
5 votes
1 answer
3k 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....
user avatar
  • 26.1k
3 votes
1 answer
202 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 ...
user avatar
1 vote
2 answers
557 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 ...
user avatar
  • 1,588
6 votes
4 answers
8k 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 ...
user avatar
  • 682
2 votes
1 answer
427 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 # ...
user avatar
  • 1,048
23 votes
3 answers
5k 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 ...
user avatar
  • 4,505
3 votes
1 answer
424 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 -...
user avatar
  • 2,156
2 votes
1 answer
751 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?
user avatar
  • 2,436
4 votes
1 answer
1k 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 ...
user avatar
7 votes
1 answer
303 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, ...
user avatar
  • 988
7 votes
1 answer
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-...
user avatar
  • 65.9k