-1

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

7
  • 2
    Please don't crosspost. Commented Mar 13, 2015 at 18:46
  • What version of Ubuntu do you have? Commented Mar 13, 2015 at 19:54
  • @MarkPlotnick Ubuntu-12.04-LTS-i386 Commented Mar 13, 2015 at 20:29
  • This should be closed on principle... Commented 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. Commented Mar 14, 2015 at 1:22

1 Answer 1

4

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

2
  • I couldn't find any folder named /usr/share/bash-completion/ Commented Mar 13, 2015 at 19:16
  • @VinuKevy On Ubuntu 12.04, those functions are in /etc/bash_completion . Commented Mar 16, 2015 at 15:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.