How can I alias to `!!` (last command)?
5,531
alias dl='fc -s'
See http://www.gnu.org/software/bash/manual/bashref.html#Bash-History-Builtins
Related videos on Youtube
Author by
Владислав Щербин
Updated on September 18, 2022Comments
-
Владислав Щербин almost 2 years
!!
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?
-
Владислав Щербин over 12 yearsWorks! Still curious though: What makes
!!
un-aliasable? -
Angel Todorov over 12 yearsI 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.