aboutsummaryrefslogtreecommitdiff
path: root/base/zsh/fancy-dots.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'base/zsh/fancy-dots.zsh')
-rw-r--r--base/zsh/fancy-dots.zsh24
1 files changed, 24 insertions, 0 deletions
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