zsh-autosuggestions icon indicating copy to clipboard operation
zsh-autosuggestions copied to clipboard

Match commands that begin with whitespace

Open ejuarezg opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe.

I like to prepend my commands with spaces in order to not save them to the history and prevent clutter. However, no suggestions, besides those that begin with whitespace, are given when I type commands with leading whitespace.

Describe the solution you'd like

An option that can be enabled that removes the leading whitespace from a typed command and matches the rest of the command with an entry in the history.

Describe alternatives you've considered

I've considered not prepending commands with spaces so that the suggestions work.

Additional context

I'm not familiar with ZSH scripting or else I'd give it a go. I think that this enhancement would interfere with history entries that begin with whitespace.

ejuarezg avatar Jul 21 '20 00:07 ejuarezg

I have no solution, but a workaround that I am using (for commands that I don't want to go into the history e.g. containing passwords)

  1. Type command and use completion feature
  2. Hit CTRL-A which should place the cursor at the beginning of the line
  3. Add the space and execute away

Maybe this helps you (it works for me)

AnimiVulpis avatar Mar 03 '21 09:03 AnimiVulpis

Thanks for your comment @AnimiVulpis. That's the same workaround I've been using. I'd just be a nice enhancement to have that as an option in the plugin.

ejuarezg avatar Mar 12 '21 20:03 ejuarezg

FWIW, here's what I've been using: https://github.com/stepnem/zsh-autosuggestions/commit/ce7ad0e8d4579f6e409b26683142fb1f2239ab51

Maybe it's not the best way to do it (I'm not that familiar with the code), but it works for me.

I didn't introduce a new option, as I don't see why anyone would prefer the current behavior.

stepnem avatar Nov 17 '22 11:11 stepnem

@stepnem Your commit was the solution I was looking for. Thanks!

ejuarezg avatar Nov 23 '22 17:11 ejuarezg