13

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.

bdesham
  • 15,430
  • 13
  • 79
  • 123
artemave
  • 6,786
  • 7
  • 47
  • 71

1 Answers1

19

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.
Thor
  • 45,082
  • 11
  • 119
  • 130
  • Awesome! And also useful beyond this particular use case. Thanks! – artemave Sep 04 '12 at 16:04
  • When I put this in my `.zshrc` and `exec zsh` it doesn't work, but when I type it in at the prompt it does... what am I missing? – Tom Hale Jan 26 '17 at 04:32
  • @TomHale: I am not sure. You may be overloading it in your configuration files. Try listing the current definitions with `bindkey`. – Thor Jan 26 '17 at 14:56