diff options
author | Anastasios Grammenos <anastasios.grammenos@noris.gr> | 2021-03-17 13:46:41 +0200 |
---|---|---|
committer | Anastasios Grammenos <anastasios.grammenos@noris.gr> | 2021-03-17 13:46:41 +0200 |
commit | 7288da0ba23bd7e9ca15d39446c4bf6c095b1e54 (patch) | |
tree | 32415e58e9149ac7ae26a761bd6dc4b2e5ac93c9 /conf_completion | |
parent | 0ccaa814bda420a39f4a184d655fa5cb670bf964 (diff) | |
download | conf-7288da0ba23bd7e9ca15d39446c4bf6c095b1e54.tar.gz conf-7288da0ba23bd7e9ca15d39446c4bf6c095b1e54.tar.bz2 conf-7288da0ba23bd7e9ca15d39446c4bf6c095b1e54.zip |
Update and add completion
Diffstat (limited to 'conf_completion')
-rw-r--r-- | conf_completion | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/conf_completion b/conf_completion new file mode 100644 index 0000000..ebeb482 --- /dev/null +++ b/conf_completion @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +_conf() +{ + COMPREPLY=() + local cur="${COMP_WORDS[COMP_CWORD]}" + local commands="add ls list search edit relink grep help" + if [[ $COMP_CWORD -gt 1 ]]; then + local lastarg="${COMP_WORDS[$COMP_CWORD-1]}" + case "${COMP_WORDS[1]}" in + l|ls|list) + if [[ $lastarg == "-g" ]]; then + COMPREPLY=($(compgen -W "$(conf ls -G)" -- ${cur})) + else + COMPREPLY=($(compgen -W "$(conf ls -h 2>&1 | awk -F' ' '{print $1}')" -- ${cur})) + fi + ;; + add|a) + if [[ $lastarg == "-g" ]]; then + COMPREPLY=($(compgen -W "$(conf ls -G)" -- ${cur})) + else + COMPREPLY=($(compgen -f -- ${cur})) + fi + ;; + edit|e) + COMPREPLY=($(compgen -W "$(conf ls -G) \ + $(conf ls -l | xargs -If basename f) \ + $(for g in $(conf ls -G); do \ + conf ls -g $g | xargs -If basename f | sed -e "s#^#${g}/#"; \ + done)" -- ${cur})) + ;; + esac + else + COMPREPLY=($(compgen -W "${commands}" -- ${cur})) + fi +} + +complete -F _conf conf + + |