Skip to main content

All Questions

2 votes
1 answer
136 views

How to create alias with a caret^ command?

I have a workflow that first check git diff for specific file and then add it to stage. git diff .. ^diff^add I want to give these command a alias but this one doesn't work alias da="^diff^add&...
gary's user avatar
  • 23
1 vote
1 answer
443 views

Setting up aliases for a history expansion pattern

similar to the existing $_ which I learned stands for !-1:$, I would like to create aliases for $__, $___ and so on which refer to the 2nd or 3rd -last command. I have tried adding alias "$__"='!-2:$'...
siryx's user avatar
  • 95
4 votes
1 answer
363 views

How can I alias a history expansion in zsh?

I want this to work (it needs extendedglob and histsubstpattern): alias ri='^(#b)E(?)^E${(l:2::0:)$((match[1]+1))}' But it doesn't: $ alias sss='^(#b)E(?)^E${(l:2::0:)$((match[1]+1))}' ...
HappyFace's user avatar
  • 1,620
8 votes
2 answers
1k views

Why does !! inside an alias not work?

I have this alias set in my system /etc/bashrc file: alias root="sudo !!" The intention of this being to run the last used command using sudo of course. When used, it of course appears to substitute ...
xanadu's user avatar
  • 101
63 votes
6 answers
47k views

How can I `alias sudo !!`?

I'm trying to set an alias for sudo !! in Bash. I tried alias sbb='sudo !!', but it interprets that as a literal !! and prints sudo: !!: command not found If I use double quotes, it substitutes ...
Manishearth's user avatar