Unable to undo removal in Zsh - zsh

I run at path/test
rm -r *
The tutorial says that I can undo the change by
If one of these fancyeditor commands
changes your command line in a way you
did not intend, you can undo changes
withˆ_,ifyou can get it out of your
keyboard, orˆXˆU,otherwise.
However, I did not get the files back by pressing Ctrl-x Ctrl-u or Ctrl-x-u.
I also tried ^_ unsuccessfully by pressing Shift-6 Shift-- or Shift-6--.
How can you undo the removal in Zsh?

The undo ability is a feature of the Z Line Editor, the editor that you use while typing at the command line. It lets you undo things you type on the command line, like any good text editor. But it won't let you undo commands that you execute.

You're misunderstanding. They're talking about undoing changes to the command-line, before you press enter, not undoing the results of a command.

Related

ZSH vi normal mode to move around printed text

Can I use zsh vi normal mode to move around previous commands output or the printed text in the shell to copy/yank it ?
For example in the screenshot below. I want to move to the output of ls to copy something. When I press j/k zsh cycle my command history but doesn't move up to the printed text. j/k move one line down/up only when I have multiple line command that I'm currently writing but haven't executed yet.
To the best of my knowledge, the ability to access the output of commands interactively is the domain of your terminal (-emulator), not the shell. You would use commands like sed, awk, grep, possibly in a pipe, to access, manipulate and use output you know in advance is the part you are interested in.
To access the output with keyboard shortcuts/command-keys, I suggest using the like of tmux - it allows to copy/yank from the whole terminal display as if it was a text-file in an editor.

How can I get backward-delete-word to add to the current kill-ring in zsh?

I use zsh and I would like backward-kill-word in Emacs mode to behave like Emacs (and bash, fwiw). The behaviour that I have failed to reproduce is that when I press multiple backward-kill-word Emacs adds the killed text to the cut buffer (the first item in the killring) making it possible for me to yank everything with one yank command.
How can I configure zsh to behave like this aspect of Emacs editors?
Actually, by default, Zsh's cut buffer works exactly the same as in Emacs. Just use zsh -f to start Zsh without config files and try it.
However, are you perhaps using zsh-autosuggestions or zsh-syntax-highlighting? There are bugs in these plugins that break this feature:
https://github.com/zsh-users/zsh-autosuggestions/issues/363
https://github.com/zsh-users/zsh-syntax-highlighting/issues/150#issuecomment-658381485
Fixes have been submitted, but for zsh-autosuggestions, none have yet been merged, and for zsh-syntax-highlighting, the fix won't work until Zsh 5.9 has been released.
In the meantime, though, zsh-autocomplete contains a workaround that fixes the problem. If you add that plugin, your cut buffer will start functioning like normal again.

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.zshrc
My problem is:
when my terminal enter into a git repository,
the command line will jump to the next line automatically.
the jump behavior is like this:
when I change the name of .git to .git__xx folder.
then jump behaviorstop
I swear that I did not press Enter,
the terminal jump to the next line automatically.
I guess it's caused by Anaconda and the time refresh settings in ~/.zshrc
The phenomenon is recorded in here
Did I press Enter deliberately and post this question to waste others' time?
No,here's the effect
if I press Enterto make command line jump to the next line
some unproper solution:
delete git part in theme file bullet-train.zsh-theme.
Then the phenomenon disappear,but the git display function is also disabled.
Could you tell me how to solve this bug?
Thanks for your help.

What does terminal / hyperterm display in the tab title? Is it possible to customize this?

I'm confused what data is being shown in my terminal tabs. The first part, epzio is obviously my username. But the second part, #C02S60BBG8WP, I have no idea.
Note: I use zsh combined with oh-my-zsh for my shell.
Is it possible to customize what is shown in the tab titles? I'd like to remove the epzio#C02S60BBG8WP part altogether and just display the current working directory.
Also, why do my tab titles turn blue for no apparent reason? I thought this was only supposed to happen when you had a specific process such as node running. As you can see in the screenshot below, the tic-tac-toe tab has turned blue even though nothing is happening in that tab.
Update: It seems that the solution might involve making changes to ~/.oh-my-zsh/lib/termsupport.zsh, but I'm not sure if these would get overridden when oh-my-zsh updates itself.
C02S60BBG8WP is probably your hostname; check by typing hostname.
You can change the terminal title by printing an escape sequence like this:
echo -en "\033]0;New terminal title\a"
So this should change the title to your current working directory, $PWD, substituted by a single ~ if you're in $HOME:
echo -en "\033]0;${PWD/#$HOME/~}\007"
If that doesn't work, it's probably being overridden immediately afterwards by a command that is automatically invoked by your shell. In bash, this would be PROMPT_COMMAND which on my system looks like this:
$ echo $PROMPT_COMMAND
__vte_prompt_command; printf "\033]0;%s#%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"
The zsh equivalent seems to be to define a precmd hook:
precmd() { echo -en "\033]0;${PWD/#$HOME/~}\007" }
To make that permanent, you can just put it your .zshrc.

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 collapse it back to original glob version? Or should I just disable glob expanding?
The reason I want it, is that when I am in the middle of debugging a glob and I hit Tab just to double check something, there is no way to get back and complete the pattern. I have to start from scratch.
Use the undo zle command. For example, bind it to Ctrl_:
bindkey '^_' undo
From zshzle(1):
undo (^_ ^Xu ^X^U) (unbound) (unbound)
Incrementally undo the last text modification.
redo Incrementally redo undone text modifications.

Resources