Score:0

Can bash "complete" command change so far typed input?

ng flag

I'd like to write a dynamic completion script that modifies the so far typed command.

For example if I type:

$ myapp give me a random command<tab><tab>
  • completion function would call REST endpoint with "give me a random command" payload
  • endpoint would return "ls -al" (so far I'm good)
  • complete would replace "myapp give me a random command" with "ls -al" (I need help only with this step).
$ ls -al

I don't know if it is even possible with complete command. If it is possible I need a clue how to do that, if it is not possible with complete is there any other approach I could take?

pierrely avatar
cn flag
overide tab key in custom keys, to run a script, to set a count of how many tabs pressed in a certain time frame. if one tab and say .5 second delay , pass on to normal completion (I am not sure about how to do that one)... if two tabs, run your script to randomly select from a list of commands. might be better to forget the tabs and make it for just running a random command script. and when I say run command at the end, I mean paste the text as in run xdotool to run ctl-shift-v (konsole) to paste in the random command. which you could just do with a hotkey that is not a tab -
pierrely avatar
cn flag
keys defined here /usr/include/X11/keysymdef.h all commands available. https://askubuntu.com/questions/403435/how-to-get-a-list-of-all-the-commands-available-for-ubuntu
pierrely avatar
cn flag
keys defined here /usr/include/X11/keysymdef.h all commands available. https://askubuntu.com/questions/403435/how-to-get-a-list-of-all-the-commands-available-for-ubuntu echo "whatever random command " | xsel -ib && xsel -ob' and add the paste command keys, ctrl-shist-v, with xdotool
Kragh avatar
ng flag
@pierrely thank you for your input! I decided to take a little bit different approach (bash function + xdotool) https://github.com/jkatnik/ai-bash
Score:0
ng flag

I changed my "requirements" and combined bash function with xdotool

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.