I want to run some functions (which I created in ./.bash_func) in terminal with some files located somewhere. When I type the function and hit Tab Tab I want to list the files located in ./scipts like cd ./scipts Tab Tab
- 2Please don't crosspost.jasonwryan– jasonwryan2015-03-13 18:46:44 +00:00Commented Mar 13, 2015 at 18:46
- What version of Ubuntu do you have?Mark Plotnick– Mark Plotnick2015-03-13 19:54:05 +00:00Commented Mar 13, 2015 at 19:54
- @MarkPlotnick Ubuntu-12.04-LTS-i386kevy– kevy2015-03-13 20:29:28 +00:00Commented Mar 13, 2015 at 20:29
- This should be closed on principle...jasonwryan– jasonwryan2015-03-14 01:13:29 +00:00Commented Mar 14, 2015 at 1:13
- @jasonwryan It was but I have reopened it since it is the only one of the three cross-posts that has an answer. The AU one one has been closed and the SU one is about to be. Let's keep this one open.terdon– terdon ♦2015-03-14 01:22:16 +00:00Commented Mar 14, 2015 at 1:22
| Show 2 more comments
1 Answer
I did this once:
notes () { ... } complete -F complete_notefiles notes # following based on # http://unix.stackexchange.com/questions/77009/custom-autocomplete-deal-with-spaces-in-filenames complete_notefiles () { local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=() pushd ~/Documents/Notes >/dev/null _filedir popd >/dev/null } . ~/.bash_completion_functions I found that I needed to copy 3 functions from /usr/share/bash-completion/bash_completion: _filedir, _tilde, _quote_readline_by_ref
- I couldn't find any folder named
/usr/share/bash-completion/kevy– kevy2015-03-13 19:16:37 +00:00Commented Mar 13, 2015 at 19:16 - @VinuKevy On Ubuntu 12.04, those functions are in
/etc/bash_completion.Mark Plotnick– Mark Plotnick2015-03-16 15:41:24 +00:00Commented Mar 16, 2015 at 15:41