zsh-autosuggestions
zsh-autosuggestions copied to clipboard
Match commands that begin with whitespace
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.
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)
- Type command and use completion feature
- Hit
CTRL-A
which should place the cursor at the beginning of the line - Add the space and execute away
Maybe this helps you (it works for me)
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.
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 Your commit was the solution I was looking for. Thanks!