diff --git a/README.md b/README.md index faa6212..f4a89ca 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ - [X] single binary - [X] much more suggestions available! (Roughly 10x more) - [X] Install with homebrew & macports +- [X] Interactive prompt with env variable: BIT_INTERACTIVE=true --- **Coming Soon** --- - bit anticipates when you'll need to type git status and will display it proactively @@ -163,6 +164,9 @@ Thanks to [Gitless](https://gitless.com/), [git-extras](https://github.com/tj/gi - https://blog.csdn.net/a419240016/article/details/109178001 ## Changelog +v1.1 +- [X] enhancement: enable interactive prompt (keep bit running) with env variable: BIT_INTERACTIVE=true + v1.0 - [X] enhancement: significantly more autocompletions - [X] enhancement: use fuzzy search for branch suggestions diff --git a/cmd/bit_cmd.go b/cmd/bit_cmd.go index c0bf8ac..c503b0c 100644 --- a/cmd/bit_cmd.go +++ b/cmd/bit_cmd.go @@ -23,30 +23,39 @@ var BitCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { suggestionTree, bitCmdMap := CreateSuggestionMap(cmd) - resp := SuggestionPrompt("> bit ", shellCommandCompleter(suggestionTree)) - subCommand := resp - if subCommand == "" { - return + repeat := os.Getenv("BIT_INTERACTIVE") == "TRUE" + repeatAmount := 1 + if repeat { + repeatAmount = 5000 } - if strings.Index(resp, " ") > 0 { - subCommand = subCommand[0:strings.Index(resp, " ")] - } - parsedArgs, err := parseCommandLine(resp) - if err != nil { - log.Debug().Err(err).Send() - return - } - if bitCmdMap[subCommand] == nil { - yes := HijackGitCommandOccurred(parsedArgs, suggestionTree, cmd.Version) - if yes { + + + for i := repeatAmount; i > 0; i-- { + resp := SuggestionPrompt("> bit ", shellCommandCompleter(suggestionTree)) + subCommand := resp + if subCommand == "" { return } - RunGitCommandWithArgs(parsedArgs) - return - } + if strings.Index(resp, " ") > 0 { + subCommand = subCommand[0:strings.Index(resp, " ")] + } + parsedArgs, err := parseCommandLine(resp) + if err != nil { + log.Debug().Err(err).Send() + continue + } + if bitCmdMap[subCommand] == nil { + yes := HijackGitCommandOccurred(parsedArgs, suggestionTree, cmd.Version) + if yes { + continue + } + RunGitCommandWithArgs(parsedArgs) + continue + } - cmd.SetArgs(parsedArgs) - cmd.Execute() + cmd.SetArgs(parsedArgs) + cmd.Execute() + } }, }