Skip to content

Instantly share code, notes, and snippets.

@daodao97
Created November 10, 2023 06:09
Show Gist options
  • Save daodao97/52a37dd5667e5c254ea15d54c417a514 to your computer and use it in GitHub Desktop.
Save daodao97/52a37dd5667e5c254ea15d54c417a514 to your computer and use it in GitHub Desktop.
function expand-dots() {
local MATCH
if [[ $LBUFFER =~ '^\.\.\.+$' ]]; then
LBUFFER=$LBUFFER:fs%\.\.\.%../..%
LBUFFER="cd $LBUFFER"
fi
}
function expand-dots-then-expand-or-complete() {
zle expand-dots
zle expand-or-complete
}
function expand-dots-then-accept-line() {
zle expand-dots
zle accept-line
}
zle -N expand-dots
zle -N expand-dots-then-expand-or-complete
zle -N expand-dots-then-accept-line
bindkey '^I' expand-dots-then-expand-or-complete
bindkey '^M' expand-dots-then-accept-line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment