summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-18 07:30:04 -0500
committerJeff Carr <[email protected]>2025-09-18 07:30:04 -0500
commitfec80aca170e85e9bb8c122ae2c6c2283930f252 (patch)
tree39591ce1b2b561544a31a31ba9688a386ada69cd
parent1522a2fef0ed356f12a5c9cc011cdad6b4cd4a05 (diff)
rename files
-rw-r--r--bash.Completion.go (renamed from bashCompletion.go)0
-rw-r--r--bash.new.go (renamed from bash2.go)5
-rw-r--r--bash.orig.go (renamed from bash.go)0
-rw-r--r--smartcd.test18
4 files changed, 23 insertions, 0 deletions
diff --git a/bashCompletion.go b/bash.Completion.go
index e0eb965..e0eb965 100644
--- a/bashCompletion.go
+++ b/bash.Completion.go
diff --git a/bash2.go b/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
index e0d23bd..e0d23bd 100644
--- a/bash.go
+++ b/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
+