Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

!! in bash runs last command. I find it too difficult to type given how much I use it. alias to the rescue, I presumed.

Or not. I tried:

$ alias dl='!!'               # Aliasing
$ echo Testing123             # Here's something to test on
Testing123
$ dl                          # Testing alias
bash: !!: command not found
$                             # I AM DISAPPOINT

Without quotes also fails.

What's up?

share|improve this question
1  
Aliases usually shorten the length of frequently typed commands, or adding frequently used switches. What's the point of even needing an alias for !!? –  bdowning Mar 8 '12 at 19:44
1  
@bdowning, presumably so you don't have to hit Shift and reach up in the corner of the keyboard. –  cjm Mar 8 '12 at 19:51
    
@bdowning As cjm; my Shift-finger wants a break. –  Anko Mar 8 '12 at 19:53
    
Get a dvorak. qwerty stair-step keyboards are an anachronism left over from typewriters designed to slow you down and make you hands hurt. After 20 years of emacs, my fingers are like pretzels –  bdowning Mar 8 '12 at 20:42
1  
@sr_ The clashes occurred because of the speed of typists. If you wish to continue this I suggest we move to a chat room. I don't care to continue, the less typing the better :) –  bdowning Mar 9 '12 at 13:30
show 2 more comments

1 Answer

up vote 11 down vote accepted
alias dl='fc -s'

See http://www.gnu.org/software/bash/manual/bashref.html#Bash-History-Builtins

share|improve this answer
    
Works! Still curious though: What makes !! un-aliasable? –  Anko Mar 8 '12 at 19:57
5  
I can't find anything quickly in the manual but I'm guessing that bash performs any history expansions before substituting aliases. So the shell only sees the command "!!" which clearly doesn't exist. –  glenn jackman Mar 8 '12 at 20:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.