Re:Sudo Replacement
by accrual on Friday January 20, 2023 @11:35PM
(#34463938)
I noticed and enjoy that both sudo and doas use each side of a standard qwerty keyboard to type, though doas uses 3 keys on the left while sudo has two on the left and two on the right. It made the transition a little easier for my muscle memory.
[ Parent
| on HN ]
On dvorak they're also mostly on the home row (except d), and the split is even 2-2 for both.
(aoeu)id(htns)
The neo2 layout has both in the home row.
I mapped ^S in zsh to toggle "doas" at the start of the line:
# Toggle "doas" at the start.
toggle-doas() {
[[ "${BUFFER:0:4}" = "doas" ]] &&
{CURSOR+=-5; BUFFER="${BUFFER:5}";} ||
{BUFFER="doas $BUFFER"; CURSOR+=5;}
}
zle -N toggle-doas toggle-doas && bindkey '^s' toggle-doas
Even less typing!