Skip to content

Commit 0528383

Browse files
committed
smarter bash completion
1 parent 63c9e6c commit 0528383

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

etc/bash_completion.d/sambamba

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,21 @@ _sambamba()
5151
elif [[ ${COMP_WORDS[COMP_CWORD - 2]} == "--format" || ${COMP_WORDS[COMP_CWORD - 1]} == "-f" ]]; then
5252
COMPREPLY=( $(compgen -W "sam bam json msgpack" -- $cur) )
5353
compopt +o nospace
54+
elif [[ $subcommand == "view" || $subcommand == "slice" ]]; then
55+
for word in ${COMP_WORDS[@]}; do
56+
if [[ $word == *.bam && $word != "" ]]; then
57+
eval abspath=$word
58+
COMPREPLY=( $(sambamba view -H $abspath | grep @SQ | \
59+
cut -f 2 | cut -f2 -d: 2>/dev/null | grep "^$cur") )
60+
break
61+
fi
62+
done
63+
compopt -o default
64+
compopt -o filenames
5465
else
5566
compopt -o default
5667
fi
5768
}
5869

5970
complete -o nospace -F _sambamba sambamba
71+
# vim: set syntax=sh :

0 commit comments

Comments
 (0)