12

!! 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?

Anko
  • 4,526

1 Answers1

20
alias dl='fc -s'

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

glenn jackman
  • 85,964
  • 1
    Works! Still curious though: What makes !! un-aliasable? – Anko Mar 08 '12 at 19:57
  • 7
    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 08 '12 at 20:17