scmbreeze / scm_breeze

Adds numbered shortcuts to the output git status, and much more
https://madebynathan.com/2011/10/19/git-shortcuts-like-youve-never-seen-before/
MIT License
2.82k stars 192 forks source link

Shell commands stopped getting wrapped #297

Closed grozen closed 4 months ago

grozen commented 4 years ago

Recently, built-in shell commands stopped working for my with scm_breeze. Debugging my way around, I found the culprit to be the following line in my ".git.scmbrc" file:

https://github.com/scmbreeze/scm_breeze/blob/8f5693f3452dbfa181da073bf3090c9b92614a61/git.scmbrc.example#L127

What started happening for me (and sadly I cannot say why) is that instead of wrapping each of the commands in scmb_wrapped_shell_commands my shell treated the entire string as a single command to try and wrap, which unsurprisingly didn't work.

When I changed that line to:

scmb_wrapped_shell_commands=(vim emacs gedit cat rm cp mv ln cd ls less subl code)

Everything started working again.

I'd submit a pull request but this is the sort of thing that I suspect might only work for a specific set of environments and not others. If anyone has sufficient shell-fu to handle this that would be great, however.

ghthor commented 4 years ago

I feel like I've seen this before. Which shell are you loading into [bash, zsh]?

grozen commented 4 years ago

Oh yes, that would have been a useful bit of information. I'm using zsh.

vise890 commented 4 years ago

I also started experiencing this bug. I'm also on zsh.

This is the relevant bit of code that wraps the commands. https://github.com/scmbreeze/scm_breeze/blob/8f5693f3452dbfa181da073bf3090c9b92614a61/lib/git/shell_shortcuts.sh#L26 It does not work as vim emacs gedit cat rm cp mv ln cd ls less subl code is interpreted as a single element (as @grozen has pointed out).

It seems that in other places in the file, the shwordsplit option is set to split words on spaces https://github.com/scmbreeze/scm_breeze/blob/8f5693f3452dbfa181da073bf3090c9b92614a61/lib/git/shell_shortcuts.sh#L126

and indeed conditionally setting that option before the command wrapping loop does resolve the issue.

I have no idea why an array wasn't used in the first place though ... nor if there are any downsides to it

brianpeiris commented 4 years ago

See also https://github.com/scmbreeze/scm_breeze/issues/284 and #283