Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7564095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:49:47+00:00 2026-05-30T13:49:47+00:00

In a bash completion script, suppose COMPREPLY=(aa/ba/ aa/bb/) . When the script is invoked,

  • 0

In a bash completion script, suppose COMPREPLY=(aa/ba/ aa/bb/). When the script is invoked, the completion options looks like this to the user:

$ foo aa/b<TAB>
aa/ba/
aa/bb/

However, I want to have a bit more control over how these options are displayed. In particular, I want to show only a substring of each COMPREPLY option to the user, similar to how directory completion works in bash now:

$ foo aa/b<TAB>
ba/
bb/

Is there any way of doing this in bash?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:49:49+00:00Added an answer on May 30, 2026 at 1:49 pm

    I was having the same problem and I fixed it by adjusting how I bound the completion function to the command. I know this works when you are dealing with actual files in the filesystem, I think it will work with any sort of file path like options, but I’m not sure.

    Before:

    complete -F _fubar fubar
    

    After:

    complete -o filenames -F _fubar fubar
    

    For more details: Programmable Completion Builtins

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Bash tab-completion script for Apache's Hadoop. Normally, I use zsh as
Command completion in bash(1) is quite handy; I like this feature very much. But
I have not found a tab-completion script for RubyGem in Bash/Zsh. Where can you
In bash, I believe it is possible to enable tab completion on the terminal
In bash one can escape arguments that contain whitespace. foo a string This also
For a Bash completion script I need to get all the variables from an
I get the following in including MacPorts' Bash tab completion to Zsh /opt/local/etc/bash_completion:[:48: unrecognized
Suppose we have this environment: mkdir -p /tmp/foo/bar/ export TEST=/tmp/foo Out of the box,
I would like to write a Unit Test for a (rather complex) Bash completion
I am trying to set up bash completion for a utility script I wrote,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.