Questions tagged [zsh-zle]

Tag questions related to the zsh line editor, including prompts, zle widgets, and the `zle` and `bindkey` commands

ZLE is the line editor. It's the part of the shell that deals with what you type and edit. You can extend the line editor using shell functions. The functionality available is immensely powerful.

54 questions
6
votes
1 answer

How to move the cursor position in zsh widget definition

I have this snippet: insert_sudo () { zle beginning-of-line; zle -U "sudo "; zle end-of-line; } zle -N insert-sudo insert_sudo bindkey "\es" insert-sudo But \es only appends "sudo" to the end of a line, not the beginning of line as I expected.…
Bohr
  • 1,566
  • 1
  • 16
  • 21
5
votes
1 answer

ZSH and ZLE, move to the beginning-of-line, write string, move to the end

Its not essential but it bugs me a bit, here is the fragment from my .zshrc a function/widget called add_sudo, that will go at the beginning of line, writes sudo there and then should go at the end of the line. Its bind to ctrl+f But it does not go…
DoTheEvo
  • 874
  • 1
  • 9
  • 21
4
votes
1 answer

zle reset-prompt not cleaning the prompt

I have a key binding to go up by one directory (very useful): # C-M-u: up-directory up-directory() { builtin cd .. && zle reset-prompt } zle -N up-directory bindkey '\e\C-u' up-directory It works well, except that the prompt is not really…
user3341592
  • 1,419
  • 1
  • 17
  • 36
4
votes
2 answers

Get current cursor position while drawing ZSH prompt

I'm trying to read into a variable the current cursor position (the current line number and column) into a variable, from within a function drawing the ZSH shell prompt. My goal is to display stuff below the prompt, only if there are enough empty…
Suzanne Soy
  • 3,027
  • 6
  • 38
  • 56
3
votes
0 answers

How can I use xonsh with edit-command-line in ZSH?

I'd like to open an editor buffer in ZSH using edit-command-line and have the contents of the buffer executed by xonsh. Is it possible to do this cleanly? The edit-command-line command in ZSH lets you edit a command line using your editor, which can…
emchristiansen
  • 3,550
  • 3
  • 26
  • 40
3
votes
1 answer

zsh having right prompt on same level as left using prezto

I'm new to zsh and also prezto. Now as in my bash shell I want to have the current path on the left and my current branch at the right as you can see in the picture so far so good..... ... Now the problem is the right part of the prompt is in the…
lony
  • 6,733
  • 11
  • 60
  • 92
2
votes
1 answer

Insert item into zsh array

Let's say I have an array defined as such: typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( os_icon dir vcs newline prompt_char ) Now I want to insert an item my_item into the array after vcs. I don't know what index vcs is…
Dan Neal
  • 51
  • 6
2
votes
1 answer

Always return to beginning of ZSH history after search?

ZSH history search is quite helpful, but one nit I have with it is that it moves your 'history pointer' to whereever your last search was. This is irritating if I'm typing a common command, and get landed at a spot in my history from weeks ago: > ls…
Luke Abel
  • 243
  • 2
  • 9
2
votes
0 answers

Is ZSH completion system capable of completing multiple arguments at the same time?

Scenario: Let's say a script my_online_searcher opens a browser with the search for query, where query can be multiple words long. This same script also provides a utility flag -s that shows the search engine's suggestions. E.g.: $…
mr.celo
  • 585
  • 1
  • 5
  • 17
2
votes
1 answer

How to have special/accented characters support in IntelliJ terminal

I use the IntelliJ IDEA's Embedded Local Terminal quite a lot, but there is one thing that is driving me nuts : special and accented characters do not work. This is what should but is not working : HOME key to go to the beginning of the line :…
Sébastien Nussbaumer
  • 6,202
  • 5
  • 40
  • 58
2
votes
1 answer

RPROMPT not showing on initial prompt

I'm seeing a strange issue when trying to use RPROMPT to configure my zsh prompt. I'm not using oh-my-zsh or any other plugin manager. Here is my .zshrc file: function zle-line-init { RPROMPT="foo" zle reset-prompt } zle -N…
mjswensen
  • 3,024
  • 4
  • 28
  • 26
1
vote
1 answer

Correct keybindings configuration for zsh in Alacritty

in alacritty.yml I have the following keybindings that work fine for Bash key_bindings: - { key: V, mods: Control, action: Paste, mode: ~AppCursor } - { key: C, mods: Control, action: Copy, mode: ~AppCursor } - { key: Q, mods: Control, action:…
shackra
  • 277
  • 3
  • 16
  • 56
1
vote
1 answer

How to alter the configuration of robbyrussel theme in oh-my-zsh so that the arrow appears after directory?

I have these settings in .oh-my-zsh/themes/robbyrussel file PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
1
vote
1 answer

Is there a way to check if the tab completion menu is open in ZSH

Is there a way to check if the tab completion menu is open in ZSH? I am asking this question because I want to bind the space key to accept-search so that I can accept completion with the space key, but I want to do it in a way that doesn't…
1
vote
1 answer

How zsh zle prevent variable CURSOR to be modified arbitrarily in runtime?

As the document says, the zle variable CURSOR can only be in range [0, $#BUFFER]. Test code (put it into .zshrc, the ^[OP is F1): testCursor() { echo "\nOriginal C: $CURSOR" BUFFER="a" echo "Change Buffer: $CURSOR" CURSOR=$((CURSOR+10)) …
LingSamuel
  • 496
  • 5
  • 10