linux - find based filename autocomplete in Bash script -
there command line feature i've been wanting long time, , i've thought how best realize it, got nothing...
so i'd have when start typing filename , hit tab,for example:
# git add foo<tab>
i'd run find . -name "*$1*"
, autocomplete complete path matched file command line.
what have far:
i know i'll have write function call app parameters want, example git add
. after needs catch tab-keystroke event , find mentioned above, , display results if many, or fill in result if one.
what haven't been able figure out:
how catch tab key event within function within function.
so in pseudocode:
gadd() {git add autocomplete_file_search($1)} autocomplete_file_search(keyword) { if( tab-key-pressed ){ files = find . -name "*$1*"; if( filecount > 1 ) { show list; } if( files == 1 ) { return files } } }
any ideas?
thanks.
you should take @ introduction bash completion. briefly, bash has system configuring , extending tab completion. other shells this, too, , each 1 has different way set up. using system not necessary , adding custom argument completion command relatively easy.
Comments
Post a Comment