Search code examples
shelltcshtab-completion

append to existing tcsh cmd auto-complete directive


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!


Solution

  • 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!