From fec80aca170e85e9bb8c122ae2c6c2283930f252 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 18 Sep 2025 07:30:04 -0500 Subject: [PATCH] rename files --- bashCompletion.go => bash.Completion.go | 0 bash2.go => bash.new.go | 5 +++++ bash.go => bash.orig.go | 0 smartcd.test | 18 ++++++++++++++++++ 4 files changed, 23 insertions(+) rename bashCompletion.go => bash.Completion.go (100%) rename bash2.go => bash.new.go (96%) rename bash.go => bash.orig.go (100%) create mode 100644 smartcd.test diff --git a/bashCompletion.go b/bash.Completion.go similarity index 100% rename from bashCompletion.go rename to bash.Completion.go diff --git a/bash2.go b/bash.new.go similarity index 96% rename from bash2.go rename to bash.new.go index e636ee1..631e5b4 100644 --- a/bash2.go +++ b/bash.new.go @@ -218,6 +218,7 @@ func parseArgv(argname string) *Auto { func Bash2(argname string, autocomplete func(*Auto)) { newauto := parseArgv(argname) if newauto.SetupAuto { + // --bash was passed. try to configure bash-completion doBash2(argname) os.Exit(0) } @@ -230,6 +231,10 @@ func Bash2(argname string, autocomplete func(*Auto)) { if len(os.Args) > 1 && os.Args[1] == "--auto-complete" { doHandlePB(newauto) autocomplete(newauto) + if newauto.Debug { + // check here to see if there was any completion text sent + // if not, send "reset bash newline\n" to cause bash to redraw PS1 for the user + } os.Exit(0) } diff --git a/bash.go b/bash.orig.go similarity index 100% rename from bash.go rename to bash.orig.go diff --git a/smartcd.test b/smartcd.test new file mode 100644 index 0000000..b67a5ea --- /dev/null +++ b/smartcd.test @@ -0,0 +1,18 @@ +_cd_complete() +{ + # sets local to this func vars + local cur prev all + cur=${COMP_WORDS[COMP_CWORD]} + # prev=${COMP_WORDS[COMP_CWORD-1]} + all=${COMP_WORDS[@]} + + # this is where we generate the go-arg output + GOARGS=$(smartcd --auto-complete \'$cur\' $all) + + # this compares the command line input from the user + # to whatever strings we output + COMPREPLY=( $(compgen -W "$GOARGS" -- $cur) ) # THIS WORKS + return 0 +} +complete -F _cd_complete cd +