Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote a simple completion function that is doing what I want with one exception. Its completions are not expanded when I type M-* ("insert-completions") the way file completions are.

Is this an inherent limitation or something I can enable?

I just tried this on a different computer (with a slightly different version of BASH) and it worked there.

  • Works: 3.2.25(1)-release (Linux, CentOS 5.5)
  • No-Go: 3.2.48(1)-release (MacOS X 10.6.7)

Update: I am looking for an hypothesis that might explain the discrepancy between these two systems.

share|improve this question

I just added the following code from this web page to my .bash_profile:

    local cur prev opts
    opts="--help --verbose --version"

    if [[ ${cur} == -* ]] ; then
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
complete -F _foo foo

foo -- gets expanded to foo --help --verbose --version when pressing Meta-* in

$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.

So: I cannot reproduce with the same version of bashon Mac OS X 10.6.7. Did you change your environment after installation, e.g. installing third party unix stuff via Macports/Fink/Homebrew? Try using a fresh Terminal configuration by creating a new user account.

Make sure you actually are pressing Meta -- it's configurable in Terminal. If you don't set this option, there's no Meta:

enter image description here

Do other Meta shortcuts from readline work?

If this doesn't work: Since 10.7.0 Lion is not yet commercially available I suggest you just expect pre-release software to have bugs and report them to the proper site.

share|improve this answer
Yes, other Meta- work. This is Snow Leopard. That's just what "uname -a" produces. – Randall Schulz May 6 '11 at 20:49
@Randall In your question, you wrote you use 10.7.0, which is the unreleased "Lion" scheduled for later this year. What do you press when Option is not your Meta key? You need to use an Esc sequence, i.e. first press Esc (don't hold), then press * afterwards. Also works for me. – Daniel Beck May 7 '11 at 3:59
All I can tell you is that I'm running Snow Leopoard 10.6.7 and when I run "uname -a" it says the kernel is "Darwin Kernel Version 10.7.0". It is by no means a pre-release system. And as I said, Using Option for Meta, as I've configured it, will trigger insert-completions for file system-based completion. – Randall Schulz May 8 '11 at 4:59
@Randall In that case, I suspect a problem with your completion function. I just put mine in .bash_profile. Try to do just that with the code I provided and see if it works then. – Daniel Beck May 8 '11 at 9:06
@Randall Darwin follows a different versioning scheme than Mac OS X. Whenever Mac OS X gains a minor version (10.5 -> 10.6), Darwin gains a major version (9.x -> 10.x). Please edit your post to mention the correct Mac OS X version. – Daniel Beck May 8 '11 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .