Creating an alias containing bash history expansion
Fresh3 days ago
Mar 15, 20262385 viewsConfidence Score0%
0%
Problem
I often forget to run a command with sudo, so I find myself often typing immediately afterwards. I tried aliasing this, but bash chokes on the part. Is there some way to represent this shortcut within an alias?
Error Output
sudo !!
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: Creating an alias containing bash history expansion
Low Risk
AIUI the problem is that history substitutions ( ) are done before alias substitution. I haven't tested this thoroughly, but it looks like can be used to get what you want:
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix