Wednesday, March 23, 2011

Extend your bash completion !!

I have downloaded zip file, I wanna extract it on command line.

$ unzip [tab][tab] -> if it displays only zip files instead of all files is that won't be good ?

Yes !!

here you go :

put below line(s) in your .bashrc file or in .bash_profile you are done with it !!
complete -A file -X '!*.zip' unzip

for other completions :

complete -A file -X '!*.php' php
complete -A file -X '!*.pl' perl
complete -A file -X '!*.c' gcc
complete -A file -X '!*.sh' bash
complete -A file -X '!*.gz' gunzip
complete -A file -X '!*.tgz' gunzip
complete -A file -X '!*.Z' gunzip
complete -A file -X '!*.gz' tar
complete -A file -X '!*.tgz' tar
complete -A file -X '!*.Z' tar
complete -A file -X '!*.awk' awk
complete -A file -X '!*.sed' sed
complete -A file -X '!*.zip' unzip

now you can get completion for php,perl or create for any of your favorite language.

Thanks,
Satya

No comments:

Post a Comment

Followers