I have the following bash script
cmd_complete () {
make run
echo -n "${PS1@P}" # print prompt again
}
complete -F cmd_complete -E
bind "Space:complete"
This script does the following:
- When pressing space in the terminal it triggers the terminal completion
- The terminal complete will execute the function
cmd_complete - The
cmd_completewill runmake runcommand then prints bash prompt again.
What is wrong:
- When typing a word in the terminal and press space it'll not print space
- this is because space is bound to
completefunction whether the bash line is empty or not.
What I would like to achieve is:
- To run
cmd_completewhen pressing space ONLY when the line is empty.
Documentation I checked but couldn't find what I need: