09 August 2011

Quick tip: bash completion for Bioinformatics

The default behavior for the <tab> completion can be extended by creating a new file:


${HOME}/.bash_completion
in your home.
For example, you can write your own Bash Completion for samtools, bwa or your favourite tool by adding the following line in "${HOME}/.bash_completion":

complete -f -X '!*.@(bam|sam|fasta|fa|fa.gz|fastq.gz|fasta.gz)' samtools bwa

Open a new bash and type:

$ samtools index <tab>
myfile.fastq.gz sequence.fasta


Pierre

2 comments:

Aaron Quinlan said...

Ha, that's clever. Thanks for passing this on.

Anonymous said...

great to know, I'm now using it too