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

  • Home
  • SEARCH
  • 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 7910231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:47:32+00:00 2026-06-03T12:47:32+00:00

I followed this tutorial to setup auto-completion functions for figlet / toilet . #

  • 0

I followed this tutorial to setup auto-completion functions for figlet/toilet.

# bash completion for figlet/toilet

have figlet &&
_figlet()
{
    local prev cur opts
    _get_comp_words_by_ref cur prev
    opts="-f"

    COMPREPLY=()

    case $prev in
        -f)
            local running=$(find /usr/share/figlet -name '*.flf' -printf '%P\n' | sed 's/\.flf$//')
            COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
            return 0
            ;;
        *)
            ;;
    esac

    COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )

    return 0
} &&
complete -F _figlet figlet

###################################################################################################

have toilet &&
_toilet()
{
    local prev cur opts
    _get_comp_words_by_ref cur prev
    opts="-f"

    COMPREPLY=()

    case $prev in
        -f)
            local running=$(find /usr/share/figlet -name '*.[tf]lf' -printf '%P\n' | sed 's/\.[tf]lf$//')
            COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
            return 0
            ;;
        *)
            ;;
    esac

    COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )

    return 0
} &&
complete -F _toilet toilet

_figlet and _toilet are almost identical except the pattern in find/sed commands.
How to extract a function called _figlet_toilet which takes a pattern as argument?

  • 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-06-03T12:47:33+00:00Added an answer on June 3, 2026 at 12:47 pm

    From: http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html

    After these matches have been generated, any shell function or command specified with the -F and -C options is invoked. When the command or function is invoked, the COMP_LINE, COMP_POINT, COMP_KEY, and COMP_TYPE variables are assigned values as described above (see Bash Variables). If a shell function is being invoked, the COMP_WORDS and COMP_CWORD variables are also set. When the function or command is invoked, the first argument is the name of the command whose arguments are being completed, the second argument is the word being completed, and the third argument is the word preceding the word being completed on the current command line. No filtering of the generated completions against the word being completed is performed; the function or command has complete freedom in generating the matches.


    # bash completion for figlet/toilet
    
    {
        have figlet || have toilet
    } &&
    _figlet_toilet()
    {
        local prev cur opts pat
        _get_comp_words_by_ref cur prev
        opts="-f"
    
        COMPREPLY=()
    
        case $prev in
            -f)
                case "${1}" in
                    figlet)
                        pat='flf'
                    ;;
                    toilet)
                        pat='[tf]lf'
                    ;;
                esac
                local running=$(find /usr/share/figlet -name "*.${pat}" -printf '%P\n' | sed "s/\.${pat}\$//")
                COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
                return 0
                ;;
            *)
                ;;
        esac
    
        # if '-f' is already given, then generate random string
        for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
            if [[ ${COMP_WORDS[i]} == -f ]]; then
                # COMPREPLY=("'$(fortune -sn42)'")
                return 0
            fi
        done
    
        COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
    
        return 0
    } &&
    complete -F _figlet_toilet figlet toilet
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF/RichFaces setup, and I found this tutorial . I followed it
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I have followed this tutorial here as mentioned exactly I now try to run
I followed this tutorial to setup SVN on my Fedora box http://www.ashishkulkarni.com/installing-subversion-on-fedora-linux/ It worked.
I followed the steps of this tutorial: http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/ to install the Android NDK on
I have followed this tutorial and added iAd to my app: http://bees4honey.com/blog/tutorial/how-to-add-iad-banner-in-iphoneipad-app/ But the
I'm building an ogre3d tutorial based on this setup http://www.ogre3d.org/wiki/index.php/SettingUpAnApplication#XCode I've followed all steps
I'm trying to setup mysql on my production server(Ubuntu 12.04). I followed this tutorial
I followed this tutorial: https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf However, I can't seem to set the path right.
I followed this tutorial here: http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/ It works great but when I enable CSRF

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.