bgaze
bgaze

Reputation: 1000

Dynamic current path in bash alias

I'm using following bash alias on my dev computer :

alias lamp_perm="sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX $PWD && sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx $PWD"

It works well but only for the path I've opened my console : when changing dir, alias stays relative to start path.

When changing dir, alias stays relative to start path

I'd like that the alias change permissions for current path, how can I do that?

Thanks,

Ben.

Upvotes: 1

Views: 547

Answers (1)

anubhava
anubhava

Reputation: 784998

Use a function instead of alias:

unalias lamp_perm
lamp_perm () {
    sudo setfacl -R -m u:www-data:rwX -m u:$(whoami):rwX $PWD &&
    sudo setfacl -dR -m u:www-data:rwx -m u:$(whoami):rwx $PWD
}

Upvotes: 2

Related Questions