bash completion "complete -f" not working
Hello all,
Code:
complete -d cd rmdir BUT Code:
complete -f cat e.g. Code:
complete -f -X '!*k' evince So in essence the question is that why is -f not working. These are the actual lines that might be interesting for someone. Code:
shopt -s extglob progcomp cdspell cdable_vars Code:
complete -A file cat less I'll be really thankful for a help. By the way, the following works in bash the way it should, yes for .bashrc and no for Desktop because .bashrc is a file and Desktop is a directory. So -f seems ok.. Code:
if [ -f .bashrc ] ; then echo yes; else echo no; fi cad |
(Note: The stuff below is highly experimental and I haven't tested it beyond with a few limited filenames, as I realized on completion this is too restrictive (I come across this post searching for solutions to the same problem...) - I'll explain see why later.)
Escape function - nothing special, just escapes the spaces and other special characters, I've probably missed some out...: Code:
_escape () { File completion - get the entire directory listing then select the files only: Code:
_fcomp () { Assign the above 2 functions using something like below, for the various editors: complete -F _fcomp gedit less mousepad vi vim The main problem with this implementation is that: 1 - You cannot access a file in another directory... 2 - Performance - Enumerating an entire directory and picking off the bits you want is rather slow. Best to just use quoted escape instead - something like: compgen -f -P '"' -S '"' "$searchString" - I only coded the escape function like this for self education... Hope this give you some idea... |
All times are GMT -5. The time now is 12:12 AM. |