rwxr--r--
/dev/blog

Bez Hermoso, Software Engineer @ ActiveLAMP

Months ago I found this hilarious and useful bash alias on Twitter which is a real gem. Typing the F word when I realize I forget to start with sudo when I should have is somehow satisfying.

Lately I expanded it a bit more, while also replacing the profanity with a little bit of courtesy. In .bashrc:

 
pls() {

   echo ''
   echo 'No problem!'
   echo ''

   if [ $# -eq 0 ]
   then
        sudo $(history -p !!)
   else
        sudo $@
   fi
}

Usage

The original use-case still works:

 
$ service postgresql restart
bash: service: command not found

$ pls

No problem!

[ ok ] Starting PostreSQL 9.1 database server: main.

But now you can also do this:

 
$ pls service postgresql restart

No problem!

[ ok ] Starting PostreSQL 9.1 database server: main.
comments powered by Disqus