diff --git a/root/init.go b/root/init.go index 7d5fd76..506c3ef 100644 --- a/root/init.go +++ b/root/init.go @@ -71,6 +71,18 @@ if [ -z "$IRIS_PID" ] && [ -z "$IRIS_RESCUE" ]; then export IRIS_ACTIVE_SHELL="bash" exec iris fi + +# Iris Autocomplete Hook +if [ -n "$IRIS_PID" ] && [ -n "$IRIS_FD" ]; then + _iris_bash_precmd() { + printf "IRIS_CMD_STOP\x00" >&$IRIS_FD 2>/dev/null + } + + if [[ ";$PROMPT_COMMAND;" != *";_iris_bash_precmd;"* ]]; then + PROMPT_COMMAND="_iris_bash_precmd${PROMPT_COMMAND:+;$PROMPT_COMMAND}" + fi +fi + `) case "fish": fmt.Printf(` diff --git a/root/wrapper.go b/root/wrapper.go index 652d919..6df169c 100644 --- a/root/wrapper.go +++ b/root/wrapper.go @@ -287,6 +287,14 @@ func runWrapper() { renderOverlay := func() {} isExecuting := func() bool { if isCommandActive.Load() { + // for bash: no preexec/precmd hooks, so fall back to TIOCGPGRP to detect when shell returns + if shellName == "bash" { + pgrp, pgrpErr := unix.IoctlGetInt(int(ptmx.Fd()), unix.TIOCGPGRP) + if pgrpErr == nil && pgrp == shellPGID { + isCommandActive.Store(false) + return false + } + } return true } pgrp, err := unix.IoctlGetInt(int(ptmx.Fd()), unix.TIOCGPGRP)