0

I am using zsh on my Linux boxe as well as my MAC. However, in both env, I have a "problem".

When I type " !! ", it does not work in zsh, but does in bash. More, it's really useful with "sudo !!". How can I make it work with zsh ?. Do I need to alias something in my .zshrc ?

  • This question does not really relate to sudo. For future reference perhaps it is a good idea to reword it to something like history expansion or repeat previous command. (and remove the sudo tag) – Bram Oct 22 '15 at 7:54
1

My zsh has !!

I have installed zsh right now and !! works as it works in bash.

Maybe you need to update it?

My version is 5.0.2-3ubuntu6

But if your zsh doesn't have it:

As answered here you need to add this to your .zshrc file:

alias ii='$(fc -ln -1)'

1

The BANG_HIST option is disabled for your zsh:

BANG_HIST (+K) <C> <Z>

Perform textual history expansion, csh-style, treating the character `!' specially.

This may happen through one of three methods:

  1. By setting it explicitly with set/setopt. Somewhere in your shell configuration there is a line like one of these:

     setopt NO_BANG_HIST
     setopt -o NoBangHist
     setopt +o banghist
     set -o nobanghist
     set +o BANG_hist
    

    Case does not matter and _ is ignored in the option name. BANG_HIST enables the feature and prepending NO (NO_BANG_HIST) disables the feature. -o sets the state of the feature as given by the name, +o inverts the meaning.

  2. By starting zsh with the -K command line option:

    zsh -K
    

    You also can explicitly set it with zsh +K but that can be overridden with setopt in the configuration.

  3. By starting zsh in emulation mode for either sh or ksh:

    ln -s /bin/zsh /usr/local/bin/ksh
    /usr/local/bin/ksh
    

    In that case the feature can also later be set with setopt, but not by command line option (/usr/local/bin/ksh +K does not work).

0

Ok. It seem that I had a old "set opt" options in my .zshrc causing the problem.

I find out by testing each and every item in my .zshrc. Lucky me, it was not the last options.

I will test later what specific option I need to change or remove.

Regards

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.