I can't get a simple bash autocompletion function to work. I need to autocomplete file names from a predefined directory so it will look like this:
$ cmd log<TAB><TAB>
file1.log file2.log file3.log
Where files are from /var/log/app
.
I can't get a simple bash autocompletion function to work. I need to autocomplete file names from a predefined directory so it will look like this:
$ cmd log<TAB><TAB>
file1.log file2.log file3.log
Where files are from /var/log/app
.
I found this to work as needed:
Thanks to dogbane in https://unix.stackexchange.com/questions/28283/autocomplete-of-filename-in-directory !
Put them into
~/.bashrc
To write a full-featured auto-complete function,
please take a look at
/etc/bash_completion.d/python
.I don't see the point of using
ls
when the shell can list files just fine by itself, so here's one using just the shell.