From ba23a0be9c6613d04d19d04e549dceea31af7678 Mon Sep 17 00:00:00 2001 From: Gustav Eek Date: Fri, 23 Oct 2020 00:23:15 +0200 Subject: [PATCH] [mosh] Inital on mosh bash completion --- bash_completion.d/mosh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bash_completion.d/mosh diff --git a/bash_completion.d/mosh b/bash_completion.d/mosh new file mode 100644 index 0000000..238c317 --- /dev/null +++ b/bash_completion.d/mosh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# This file provides programmable completion for repo-encrypt under +# the bash shell + +function _mosh { + + local cmd cur prev line subcmds opts + COMPREPLY=() + cmd="${1##*/}" + cur="${COMP_WORDS[COMP_CWORD]}" # called 'cur' by convention [1] + prev="${COMP_WORDS[COMP_CWORD-1]}" + line="${COMP_LINE}" + subcmds="encrypt decrypt" + opts="--help" + + if [[ "$COMP_CWORD" == 1 ]]; then + COMPREPLY=($(compgen -W "${subcmds} ${opts}" -- "${cur}")) + return 0 + elif [[ ${COMP_WORDS[1]} == "--help" ]]; then + COMPREPLY=(" ") # none empty + >&2 printf "\n${cmd}: No completion on '--help'" + return 0 + fi + + return 0 +} + +complete -o filenames -o default -F _repo-encrypt repo-encrypt # There are details [2] + +# cat ~/.ssh/config | sed -n '/^[[:space:]]*[Hh]ost/ {s/#.*$//g; s/\*//g; s/[Hh]ost\([Nn]ame\)*//g; s/[[:space:]]/\n/g; p}' |sort -u | less + +# [1]: http://tldp.org/LDP/abs/html/tabexpansion.html +# [2]: http://www.gnu.org/software/bash/manual/bash.html#Programmable-Completion -- 2.39.2