3 ms·
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" ]] &&
by arp242 4y ago
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!