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 4272674
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:36:34+00:00 2026-05-21T07:36:34+00:00

I created a simple bash function : http://shr.im/ionyse-notify I would like to add a

  • 0

I created a simple bash function : http://shr.im/ionyse-notify

I would like to add a little completion file.

I found two interesting functions :

  • _known_hosts
  • _user_at_host

How can I say that for the first argument, it should complete using _known_hosts and for the second using _user_at_host

#!/bin/bash

_send-msg_complete()
{
  local cur prev

  COMPREPLY=()
  cur=${COMP_WORDS[COMP_CWORD]}
  prev=${COMP_WORDS[COMP_CWORD-1]}

  if [ $COMP_CWORD -eq 1 ]; then
      COMPREPLY=( $(compgen -F _known_hosts -- $cur) )
  elif [ $COMP_CWORD -eq 2 ]; then
      COMPREPLY=( $(compgen -F _user_at_host -- $cur) )
  fi

  return 0
} &&

complete -F _send-msg_complete send-msg

Here is what I have, but it doesn’t work. What’s wrong ?

  • 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-21T07:36:35+00:00Added an answer on May 21, 2026 at 7:36 am

    Actually, it is quite simple :

    #!/bin/bash
    
    _send-msg_complete()
    {
      local cur prev
    
      COMPREPLY=()
      cur=${COMP_WORDS[COMP_CWORD]}
      prev=${COMP_WORDS[COMP_CWORD-1]}
    
      if [ $COMP_CWORD -eq 1 ]; then
          _known_hosts
      elif [ $COMP_CWORD -eq 2 ]; then
          _user_at_host
      fi
    
      return 0
    } &&
    
    complete -F _send-msg_complete send-msg
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a simple BaSH-like grammar on ANTLRv3 but haven't been able
How to manually create Friendly URLs? (PHP) So I have created simple php file
I'm trying to write (what I thought would be) a simple bash script that
I have created a simple bash script, chmod +x, and successfully am running it
The problem is simple: Using bash, I want to add a directory to my
I've found a great little program that will allow me to add user friendly
I've created a really simple bash script that runs a few commands. one of
I am trying to write a simple utility function in Bash, which will perform
In bash, I have created a simple daemon to execute commands when my internet
I created a simple shell script: #!/bin/bash clear echo Starting Script now..... echo Write

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.