Questions tagged [zsh-zle]
Tag questions related to the zsh line editor, including prompts, zle widgets, and the `zle` and `bindkey` commands
45
questions
0
votes
1answer
14 views
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 ...
0
votes
0answers
10 views
Hook for when zle adds typeahead characters to the buffer
Is there a hook to determine when typeahead characters were added to the ZLE buffer? The line-init hooks fires right before typeahead characters are added (which makes since since the typeahead ...
0
votes
1answer
50 views
How can I keybind Ctrl-C to vi-kill-line only when in viins mode?
What I want to achieve is to bind Ctrl-C to clearing the line without issuing a newline (à la ipython) only when editing the command line, while keeping Ctrl-C as the interrupt signal triggerer when a ...
1
vote
1answer
50 views
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, ...
1
vote
1answer
64 views
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="...
0
votes
0answers
62 views
after reset-prompt,the command line jump to next line automatically
①I have tried to use an dynamic clock with time refresh settings in ~/.zshrc
TMOUT=1
TRAPALRM ()
{ zle reset-prompt }
②my full modified theme file is bullet-train.zsh-theme
my whole ~/.zshrc file is....
0
votes
1answer
165 views
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
...
1
vote
0answers
145 views
Is ZSH completion system capable of completing multiple arguments at the same time?
Scenario:
Let's say a script my_online_searcher <query> opens a browser with the search for query, where query can be multiple words long. This same script also provides a utility flag -s <...
0
votes
1answer
151 views
Make zsh zle restore characters on backspace in vi overwrite-mode
I am using Zsh in Vi-mode.
When $KEYMAP == vicmd (i.e. command-mode), I want hitting backspace to move the cursor to the left by one character, without deleting anything. [working]
When $KEYMAP == ...
1
vote
1answer
113 views
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 ...
5
votes
1answer
1k views
zsh: refresh prompt after running zle widget
I have the following widget defined
function cdd()
{
cd /
}
zle -N cdd{,}
bindkey "^R" cdd
After pressing the key combination the cwd is already changed, but the terminal prompt is not updated. ...
19
votes
2answers
2k views
widgets can only be called when ZLE is active
I have been dealing with this problem for almost a month now, and I feel frustrated, Any help would be greatly appreciated.
I am trying to write a widget for my takenote command. The purpose of the ...
0
votes
1answer
178 views
Create custom accept-line to measure time taken by a command to run in zsh
I want to measure the time taken by a program to run in zsh. Based on the time difference, I want to print out the time taken. I edited the accept-line hook function for this:
my-accept-line () {
...
1
vote
1answer
163 views
zle backward-char not working as expected
I'm writing a simple ZLE widget to quickly create subshells with <C-j>. Here's what I have:
function zle_subshell {
zle -U '$()'
zle .backward-char
}
# register as widget
zle -N ...
0
votes
0answers
291 views
Use OS X clipboard with zsh vi-mode
I am using vi-mode with zsh at the moment. I am also using this to get a visual mode so I can include this in the right prompt.
I haven't yet been able to get this to work with OS X clipboard, pbcopy ...
4
votes
2answers
931 views
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 ...
1
vote
0answers
253 views
zsh clears previous line of prompt
I have a multi-line prompt in zsh. I've found that sometimes when I CTRL-C out of an autocompletion the previous line of the prompt gets erased unexpectedly. Here's a gif showing this happening with ...
1
vote
2answers
174 views
Recover an interrupted command in zsh
In zsh, if one accidentally interrupted a command (^C), is there a quick way to recover the full interrupted command line?
For example,
PROMPT $ this is a long command ^C
PROMPT $ [cursor here]
I ...
2
votes
1answer
573 views
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 :
...
2
votes
1answer
292 views
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"
...
1
vote
0answers
106 views
Asynchronous zle (zsh line editor)
I've modified my zsh to always guess/autosuggest what I'm trying to type by modifying self-insert to run a guess function that interprets and modifies $BUFFER after running the default zle .self-...
0
votes
1answer
66 views
widgets for case manipulation: `gU` in normal and `U` in visual mode
I reckon there's already a widget for the g~ action in zle. So g~iw will invert the case of a word.
I read the zshzle manual and did not find a widget that would give me the behaviour of gU (...
0
votes
1answer
220 views
How to correctly bind `<esc>` in zle vi visual mode in zsh 5.0.8
The standard behaviour of <ESC> zle vi-mode when in visual mode is to do nothing. But I want that the action of pressing <esc> in vi-mode visual mode switches the keymap to vi-normal mode (...
3
votes
1answer
566 views
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 ...
1
vote
0answers
61 views
Is there a way to clear the message below the command line (zle -M “message”) if a different widget runs?
I have a zsh/zle widget that is usually/often run multiple times in a row. I would like to display a message using zle -M but if a widget OTHER than mine runs I would like to clear the message. Is ...
0
votes
1answer
278 views
Send a simulated keypress from ZLE script to terminal
Is it possible to simulate a keypress from withing zle function?
test (){
BUFFER="sudo $BUFFER"
CURSOR=$#BUFFER
<??send right-arrow keypress??>
}
zle -N test
bindkey "^f" test
I feel it would ...
1
vote
1answer
337 views
Avoid adding zsh command to history
I use the following binding to allow me to press Control-Z to resume a program I previously backgrounded. I set histoptignorespace and put a space in front of fg so the command doesn't persist in my ...
3
votes
1answer
1k views
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 ...
0
votes
1answer
121 views
Why can't I grep zle from setopt?
I came across this by chance, and it's been nagging me since:
% setopt
alwaystoend
autocd
autonamedirs
...
sharehistory
shinstdin
zle
%
% setopt | grep zle
# nothing printed
%
% setopt | cat -vet
...
1
vote
3answers
630 views
zsh history completion with sudo
I was wondering if there is a feature where you get history completion (by pressing UP and DOWN) for the command but also for the already entered arguments, this would be really convenient with sudo, ...
0
votes
1answer
263 views
Zsh ZLE widget “edit-command-line” returns with an error
When I invoke this widget with ^x^e and then exit the visual editor (vim), the current command is aborted with an error and the command contents is put on the next command line to be executed.
What I ...
25
votes
6answers
11k views
Inserting a newline in a multiline zsh command pulled from history
Sometimes I use multiline commands in zsh:
❯ echo \
> a \
> multiline \
> command
When editing the command after pulling it from a history search, I can change the content of individual ...
11
votes
4answers
3k views
Multi-dot paths in zsh, like `cd …`
All shells understand these commands:
$ cd .
$ cd ..
And zsh will also understand:
$ cd ...
$ cd ....
Provided you say:
$ alias -g ...='../..'
$ alias -g ....='../../..'
Now, how can I make it ...
4
votes
1answer
740 views
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 ...
0
votes
1answer
115 views
zsh-bindings: noremap on vi mode
I want to bind 'dd' in the zsh's vicmd into something like 'ddi', If i use:
bindkey -M vicmd -s dd 'ddi'
It will give me this output:
zsh: string inserting another one too many times
19
votes
8answers
16k views
zsh new line prompt after each command
Can I configure my prompt to show a new line after each command?
To give you an example. In the following screenshot I did run cat .zshrc. I want to have a new line between the last output line of ...
15
votes
1answer
4k views
ZSH on 10.9: widgets can only be called when ZLE is active
I am new to ZSH and have been using oh-my-zsh to rum ZSH on OSX 10.9. I've been trying to take an advantage of a history plugin but I get this, "widgets can only be called when ZLE is active." when ...
44
votes
6answers
40k views
List of zsh bindkey commands
Where can I find a list of zsh commands that I can use with bindkey, with descriptions?
Each time that I look for name of some standard action (e.g., end-of-line), I need to google and guess that the ...
37
votes
6answers
13k views
zsh: update prompt with current time when a command is started
I have a zsh prompt I rather like: it evaluates the current time in precmd and displays that on the right side of the prompt:
[Floatie:~] ^_^
cbowns% [9:28:31 on 2012-10-29]
...
8
votes
2answers
2k views
zsh preexec command modification
Is there a way to modify the command that is about to execute?
I would like to redirect the output to a file, as well as print it on the terminal.
I found that ls > file.txt | cat does the job, so ...
12
votes
1answer
1k views
zsh: how to get back 'unexpanded' command
Zsh has a nice feature of expanding globs. For example, hitting Tab turns ls **/*.js into
ls app/assets/javascripts/application.js vendor/assets/javascripts/Markdown.Converter.js
Is there a way to ...
10
votes
2answers
5k views
Zsh zle shift selection
How to use shift to select part of the commandline (like in many text editors) ?
16
votes
2answers
8k views
Interpret zsh bindkey escaped sequences
I usually find interesting zsh keybinding settings (through bindkey command) around the web. My question is how do I interpret what these escaped sequences mapped to? For instance, here is a snippet ...
0
votes
3answers
1k views
How can I maintain my last command’s exit-status while resetting my prompt in ZSH?
I’m trying to make an über-simple (single-character) prompt that gives me as much information as possible. Here’s what I have at the moment (had it for ages, can’t remember where I found the original):...
12
votes
3answers
7k views
Constantly updated clock in zsh prompt?
I know that I can exec a date command in my zsh prompt.
However, it shows the old time; to see the current time, I have to hit <return> and get a new prompt with the current time.
Is there a ...