EternalTerminal icon indicating copy to clipboard operation
EternalTerminal copied to clipboard

bash/zsh completion?

Open AndrewSB opened this issue 4 years ago • 3 comments

Hey! I couldn't find documentation or any issues about this:

Does et support shell completion? specifically interested in tab completion for hosts in my ssh config

Thank you for continuing to maintain this great package

AndrewSB avatar May 09 '20 18:05 AndrewSB

Not yet but it's a good idea

MisterTea avatar May 09 '20 18:05 MisterTea

I've just wrote a bash-completion script by modify the mosh one, and tested very simply. Would you try it and if it works, merge it into the main tree.

# Bash completions for Eternal Terminal (ET).         -*- shell-script -*-

__et_init_completion()
{
    if declare -F _init_completions >/dev/null 2>&1; then
        _init_completion
    else
        COMPREPLY=()
        _get_comp_words_by_ref cur prev words cword
    fi
}

_et () {
    local cur

    __et_init_completion || return

    local simple_flags="-N -h -u -p -r -x -v -f"
    local flags="--version --username --host --port --command --prefix
    --reversetunnel --jumphost --jport --kill-other-sessions --verbose
	--logtostdout --silent --no-terminal --forward-ssh-agent --ssh-socket
	--serverfifo"

    if [[ "$cur" == --* && "$COMP_CWORD" == 1 ]]; then
        COMPREPLY=($(compgen -W "$flags" -- "$cur"))
    elif [[ "$cur" == -* && "$COMP_CWORD" == 1 ]]; then
        COMPREPLY=($(compgen -W "$simple_flags" -- "$cur"))
    else
        _known_hosts_real -a "$cur"
    fi
}

complete -o nospace -F _et et

How to try: Just copy it to /usr/local/etc/bash_completion.d/et

Cuz I'm not familiar with the installation script, so I did not make a PR. Forgive me.

tgarm avatar Aug 24 '20 08:08 tgarm

Does the above script read from ~/.ssh/config ? How to add from https://github.com/Bash-it/bash-it/blob/master/completion/available/ssh.completion.bash ?

xgdgsc avatar Nov 13 '20 03:11 xgdgsc