Skip to content

Commit

Permalink
Extend bash completion to profile and layout
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzozowski committed Oct 9, 2021
1 parent 5b562f3 commit fe3e6f0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions completion/bash
Expand Up @@ -5,10 +5,15 @@ _terminator()
local cur prev words cword
_init_completion || return

COMPREPLY=($(compgen -W "$($1 --help | tr ',' '\n' |
command sed -n -e 's/ *\(--\?[a-zA-Z\-]\+=\?\).*/\1/p')"\
-- "$cur"))
} &&
complete -F _terminator terminator
local OPTS_FILTER='s/.*\(--[-A-Za-z0-9]\{1,\}=\{0,1\}\).*/\1/p'
local exe_opts=$($1 -h 2>&1 | sed -ne $OPTS_FILTER | sort -u)

# ex: filetype=sh
if [[ "${prev}" == "--profile" || "${prev}" == "-p" ]]; then
COMPREPLY=($(compgen -W "$($1 --list-profiles | tr -d \' | sed 's/[][,]//g')" -- ${cur}))
elif [[ "${prev}" == "--layout" || "${prev}" == "-l" ]]; then
COMPREPLY=($(compgen -W "$($1 --list-layouts | tr -d \' | sed 's/[][,]//g')" -- ${cur}))
else
COMPREPLY=($(compgen -W "${exe_opts}" -- ${cur}))
fi
} &&
complete -F _terminator terminator

0 comments on commit fe3e6f0

Please sign in to comment.