I want to be able to run a command, it fails cause it doesn't have proper permissions. Then I can write "please" to sudo the command I just ran.
Here's what I want to do in the terminal:
$ run command
"you don't have access to do that"
$ please
"ran successfully"
I saw that !!
will grab the previous command, so I thought I could use that, but I can't get it to work.
my please.sh shell script looks like this, but I can't get any of these to work. It just says "command not found !!" and prints out the sudo usage.
#!/bin/zsh
#sudo !!
#sudo `!!`
sudo $(!!)
sudo !!
does it run as expected? I think !! may just be a bash alias, so it may not work in zsh – Chris Wayne Jul 19 '12 at 1:07!!
and others) only works in interactive shells and not in scripts. – Thor Jul 19 '12 at 1:16sudo !!
in interactive mode almost works as expected. when I pressed enter it would replace!!
with the previous command. then i had to press enter again to run it. – jb. Jul 19 '12 at 2:53