[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] Request For New Feature: Unadorned Plus Sign
From: |
Ralph Corderoy |
Subject: |
Re: [Nmh-workers] Request For New Feature: Unadorned Plus Sign |
Date: |
Fri, 10 Feb 2012 22:58:24 +0000 |
Hi Norm,
> Folder name completion was what I wanted for. I guess that it's not to
> be.
I did work out the tcsh(1) spell for that in another millenium, these
days I use bash as it's what to hand. I've had a go at what you
requested and it seems to work; I don't use it myself and haven't tried
to define a bash completion before so be warned.
comp_nmh_folder()
{
local w=${COMP_WORDS[COMP_CWORD]} &&
[[ $w == +* ]] && w=${w#+} &&
COMPREPLY=($(
folders -fast |
awk -v "w=$w" -v "l=${#w}" 'substr($0, 1, l) == w'
))
}
complete -P + -F comp_nmh_folder -D
It assumes if you are completing a word starting with a plus that it's a
folder. It does this for all commands, -D for default, not a hard-coded
list of scan, refile, ... That way it works with your ~/bin. Tap Tab
multiple times for a list of possible completions.
Cheers, Ralph.