bash_completion per dsh

dsh és el milloret que he trobat per llençar comandes via SSH.

$ dsh --group workers 'uptime'

Però no he trobat cap fitxer per fer funcionar la ‘bash-completion’, i a aquestes alçades sóc un adicte al tabulador. Així que… “scratch your itch”.

### Bash-completion for dsh.
### Copyright 2011  Jordi Funollet <jordi.f@ati.es>
### Distributed under the terms and conditions of GPL version 2

_dsh() {
    _get_comp_words_by_ref cur prev
    COMPREPLY=()

    case "${prev}" in
        -m|--machine)
            _known_hosts_real "${cur}"
            return 0
            ;;
        -f|--file)
            _filedir
            return 0
            ;;
        -g|--group)
            local groups=$(cd ~/.dsh/group/ && find *)
            COMPREPLY=( $(compgen -W "${groups}" -- "${cur}") )
            return 0
            ;;
        *)
            ;;
    esac

    opts="$(dsh --help | awk '/^-/ {print $1,$2}')"
    COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
    return 0
}

complete -F _dsh dsh
This entry was posted in codi-lliure and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>