skip to Main Content

Howto correct sitecopy bash autocompletion in Ubuntu 12.04

If you like me use sitecopy to easilly maintain remote websites over FTP, you also find annoying that bash autocompletion doesn’t work as expected in Ubuntu 12.04. In this post I’ll show you how to happily solve this issue.

Say you have a website configured in your ~/.sitecopyrc named mywebsite. If you try to update it remotely, by issuing:

$ sitecopy -u myweb

and then pressing TAB expecting the word mywebsite to be autocompleted, you’ll see something like this in your terminal:

grep: Unmatched [ or [^

And no completion will occur.

To correct this wrong behavior you can edit the file /etc/bash_completion.d/sitecopy (you’ll need root access to the file to do that).

Find the line:

COMPREPLY=( $( compgen -W "$(command grep '^["$'\t '"]*site' \
~/.sitecopyrc | awk '{print $2}')" -- "$cur" ) )

And modify it like this

COMPREPLY=( $( compgen -W "$(command grep '^site' \
~/.sitecopyrc | awk '{print $2}')" -- "$cur" ) )

You’ll lose the possibility to have whitespace, tabs, etc before sites configuration in your ~/.sitecopyrc, but in my case this was not a real issue.

Please let me know if you found a more elegant solution to this issue. 🙂


Freelance developer and sysadmin

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top