Auto/Tab completion

Home Forums Feature requests Auto/Tab completion

This topic contains 4 replies, has 4 voices, and was last updated by  mikey 3 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1412

    simon
    Participant

    Hi,

    It would be fantastic to be able to auto complete site names and plugins/themes using the tab key ala command-line completion!

    Thanks

    Simon

    #1417

    WordShell.Net
    Keymaster

    Hi Simon,

    This bash completion script can complete site names. You’re welcome to send us an enhancement to complete other things if you have time to extend it!

    # bash completion for wordshell
    #
    
    # This file must be updated with any changes to, or additions to the options.
    
    _wordshell_completion()
    {
        local cur prev prev_prev sites site
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        prev="${COMP_WORDS[COMP_CWORD-1]}"
    
        [[ $COMP_CWORD -eq 1 && -f $HOME/.wordshell/rc ]] || return 0
    
        case "${cur}" in
            *)
                sites=grep "^d*site#" $HOME/.wordshell/rc | cut -d# -f2 | grep ^$cur
                oldIFS="$IFS"
                IFS='
                '
                IFS=${IFS:0:1} # this is useful to format your code with tabs
                COMPREPLY=( $sites )
                IFS="$oldIFS"
    
                return 0
                ;;
        esac
    
        return 0
    }
    complete -F _wordshell_completion wordshell
    

    David

    #1482

    PaulinHalenria
    Participant

    Hi David,

    How should we invoke this script ?
    the variable assignment to “sites” sounds a little but corrupted by the editor. Or is it normal to have and " ?

    #1566

    mikey
    Participant

    I am interested in this as well but am not very familiar with bash so can’t figure out how to fix line 17.

    At the moment I’ve changed it to sites=grep 'site#' $HOME/.wordshell/rc | cut -f2 -d'#' | grep ^$cur but this causes the error: wordshell site#: command not found

    Help would be appreciated!

    testing
    testing2
    test3

    • This reply was modified 3 months, 2 weeks ago by  mikey. Reason: testing backticks
    #1568

    mikey
    Participant

    Ok worked it out… Should’ve been obvious when I used code tags (`) in my previous post.

    Line 17 should be something like:

    sites=~grep '^d*site#' $HOME/.wordshell/rc | cut -f2 -d'#' | grep ^$cur~

    But you have to replace the ~ characters with backticks!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Posted in

Tax country

Taxes will be calculated using the country you choose here.

Cart

Meta

  • Your profile

Recent Comments