By golly, I’ve finally done it! I love bash completion and must have it on any shell-based device I own. I’ve written countless numbers of scripts but for the most part, they’re fairly self-contained — with the exception of the “perms” script. This script is nice and quick on a one-site box where I can just run “perms” and my permissions for a set get reset to “production”. I use this so that when doing WordPress updates for example, I can chmod -R 777 then run perms after all my updates — nice and quick! 🙂
Servers running multiple sites require a more complex perms script which accepts a $1 variable of the domain. From there, I run the specific chowns and chmods and what not for that particular site using a case as well as some defaults that affect all the sites.
I’ve found it annoying to have to type “perms beshoy.girgis.us” or “perms odslabs.com” so I made a quick script to take care of the domain part for me. This script gets dropped in /etc/bash_completion.d/perms
# bash completion for perms _perms() { cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $( compgen -W "$(ls /vhosts/)" -- $cur ) ) } complete -o default -o nospace -F _perms perms