0

I would like to append more parts to the existing command completion (do not have access to the first creation.)

the following does not work:

complete myscript.py `complete myscript.py` 'n,-t,(t1 t2),'

It adds extra ticks (') and the auto-complete is broken.

Would love to see a working example. Thanks!

dv-guy
  • 1
  • 1

2 Answers2

0

So you just need to strip away the extra quotes that you are getting when you ask how myscript.py completes.

complete myscript.py `complete myscript.py | sed s/\'//g` 'n,-t,(t1 t2),'

That should solve the problem of the extra quotes (though if your existing complete patterns contain quotes that you need then you'll need a more complex sed pattern to properly clean up that output).

thomasafine
  • 131
  • 1
  • 4
  • This was the first solution I've tried when encountered the problem :) I actually tried a more complex regexp: sed 's/^.\(.*\).$/\1/' But the result was a broken complete command. – dv-guy Jan 10 '21 at 10:57
0

I couldn't find a way to append to the existing complete, so I've decided to create a new file on-the-fly within my cshrc and source is, overriding the prev complete directive:

set filename = `date '+%Y-%m-%d-%H-%M-%S'`
set cmd_arr  = ( scrpt1.py scrpt2.py scrpt3.py )

foreach c ($cmd_arr)
  complete | grep $c | sed  's;$; \'n,-r,`/home/\$USER/complete_rev.py`,\';' |  sed 's/^/complete /' >> $filename
end

source $filename
rm $filename -f

C'est tout!

dv-guy
  • 1
  • 1