From b5a3ecb81eadda4c48a97dd8099b07bb453219f1 Mon Sep 17 00:00:00 2001 From: Alexis Hovorka Date: Sun, 4 Jul 2021 19:44:28 -0600 Subject: [feat] Add zsh .... path expansion --- base/zsh/fancy-dots.zsh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 base/zsh/fancy-dots.zsh diff --git a/base/zsh/fancy-dots.zsh b/base/zsh/fancy-dots.zsh new file mode 100644 index 0000000..def0e22 --- /dev/null +++ b/base/zsh/fancy-dots.zsh @@ -0,0 +1,24 @@ +# Based on http://stackoverflow.com/a/41420448/4757 + +function expand-multiple-dots() { + local MATCH + if [[ $LBUFFER =~ '(^| )\.\.\.+' ]]; then + LBUFFER=$LBUFFER:fs%\.\.\.%../..% + fi +} + +function expand-multiple-dots-then-expand-or-complete() { + zle expand-multiple-dots + zle expand-or-complete +} + +function expand-multiple-dots-then-accept-line() { + zle expand-multiple-dots + zle accept-line +} + +zle -N expand-multiple-dots +zle -N expand-multiple-dots-then-expand-or-complete +zle -N expand-multiple-dots-then-accept-line +bindkey '^I' expand-multiple-dots-then-expand-or-complete +bindkey '^M' expand-multiple-dots-then-accept-line -- cgit v1.2.3-70-g09d2