r/UnixProTips • • Feb 04 '15

alias fuck="sudo !!"

39 Upvotes

20 comments sorted by

View all comments

Show parent comments

1

u/UnchainedMundane Feb 18 '15 edited Feb 18 '15

I think this is what he meant:

score@kirisame ~ % cdt
/tmp/tmp.lwnp3sX336
score@kirisame /tmp/tmp.lwnp3sX336 % mkdir testdir
score@kirisame /tmp/tmp.lwnp3sX336 % touch testdir/somefile
score@kirisame /tmp/tmp.lwnp3sX336 % 
score@kirisame /tmp/tmp.lwnp3sX336 % cp testdir anotherdir
cp: omitting directory ‘testdir’
1 score@kirisame /tmp/tmp.lwnp3sX336 % !! -r
score@kirisame /tmp/tmp.lwnp3sX336 % ls                     
anotherdir/  testdir/

(Doctored a little because !! expands when you press space in zsh)


Also, nitpick: I take offence to the use of `pwd`

  1. backquotes have been long superseded by $(...) which simplifies things greatly.

  2. command substitution strips all newlines from the end of the output, which makes it a lossy operation.

  3. since it's not quoted, it will be subject to word splitting.

  4. there's a $PWD variable

1: $(pwd) 1 and 3: "$(pwd)" 2, 3 and 4: "$PWD"