bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange compgen behaviour


From: Mathias Dahl
Subject: Re: Strange compgen behaviour
Date: Fri, 25 Sep 2009 04:47:04 -0700 (PDT)
User-agent: G2/1.0

> This has been an interesting topic!

I thought I should share the final version as well:

_mm() {
    local cur files
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    files=$(find /home/mathias/Videos/movies/ -iname "*.avi" -type f -
printf "%P\n" | grep "${cur}" | sed "s/\\([][\\(\\) ,\']\\)/\\\\\\1/
g")
    local IFS=$'\n'
    COMPREPLY=(${files})
}

complete -F _mm mm

And the `mm' script needs to append the root folder, of course, like
so:

#!/bin/bash
mplayer "/home/mathias/Videos/movies/$1"

Works quite well. Maybe it will be useful to someone else too.

/Mathias


reply via email to

[Prev in Thread] Current Thread [Next in Thread]