From dc89617cdda10aad9ebd4d8aae7d86ff032374b8 Mon Sep 17 00:00:00 2001 From: Frank Barknecht Date: Mon, 26 Dec 2005 18:29:50 +0000 Subject: added completion for -path, -helppath and -open svn path=/trunk/; revision=4299 --- scripts/bash_completion/pd | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'scripts/bash_completion/pd') diff --git a/scripts/bash_completion/pd b/scripts/bash_completion/pd index 9210fcdd..e7af0011 100644 --- a/scripts/bash_completion/pd +++ b/scripts/bash_completion/pd @@ -1,19 +1,17 @@ # # bash_completion file for Pd. # -# Save as: /etc/bash_completion.d/pd or ~/.bash_completion and enjoy -# never having to type any full command line option anymore. Instead you -# can press . +# Save as: /etc/bash_completion.d/pd or ~/.bash_completion and enjoy never +# having to type any full command line option anymore. Instead you can press +# . # -# Later add some more fine grained settings, like having "-path" -# only complete on directory names etc. If you want to help, these are -# fine introductions to bash's completion feature: +# If you want to help, these are fine introductions to bash's completion +# feature: # # http://www.debian-administration.org/articles/316 # http://www.debian-administration.org/articles/317 # -# First version written by Frank Barknecht -# Dec 26 2005 +# First version written by Frank Barknecht Dec 26 2005 have pd && _pd() @@ -21,7 +19,9 @@ _pd() local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" - #prev="${COMP_WORDS[COMP_CWORD-1]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + # Pd's options: opts="-help \ -r \ -audioindev \ @@ -70,6 +70,28 @@ _pd() -realtime \ -nrt" + + # options that require an argument: + case "${prev}" in + # directory argument: + # TODO: colon-separated paths as in "/usr/lib/pd/extra:/home/user/pd" + -path) + COMPREPLY=( $(compgen -d ${cur}) ) + return 0 + ;; + -helppath) + COMPREPLY=( $(compgen -d ${cur}) ) + return 0 + ;; + # patch file argument: + -open) + _filedir '@(pd|pat)' + return 0 + ;; + *) + ;; + esac + if [[ ${cur} == -* ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) else -- cgit v1.2.1