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. 🙂

Advertisements

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s