]> git.madduck.net Git - etc/zsh.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

mkdir in place
authormartin f. krafft <madduck@madduck.net>
Sat, 5 Nov 2011 09:14:53 +0000 (10:14 +0100)
committermartin f. krafft <madduck@madduck.net>
Sat, 5 Nov 2011 09:15:28 +0000 (10:15 +0100)
.zsh/zshrc/80_inplacemkdir [new file with mode: 0644]

diff --git a/.zsh/zshrc/80_inplacemkdir b/.zsh/zshrc/80_inplacemkdir
new file mode 100644 (file)
index 0000000..095200f
--- /dev/null
@@ -0,0 +1,28 @@
+# from grml
+_inplaceMkDirs() {
+    local PATHTOMKDIR
+    if ((REGION_ACTIVE==1)); then
+        local F=$MARK T=$CURSOR
+        if [[ $F -gt $T ]]; then
+            F=${CURSOR}
+            T=${MARK}
+        fi
+        # get marked area from buffer and eliminate whitespace
+        PATHTOMKDIR=${BUFFER[F+1,T]%%[[:space:]]##}
+        PATHTOMKDIR=${PATHTOMKDIR##[[:space:]]##}
+    else
+        local bufwords iword
+        bufwords=(${(z)LBUFFER})
+        iword=${#bufwords}
+        bufwords=(${(z)BUFFER})
+        PATHTOMKDIR="$bufwords[iword]"
+    fi
+    [[ -z "${PATHTOMKDIR}" ]] && return 1
+    if [[ -e "${PATHTOMKDIR}" ]]; then
+        zle -M " path already exists, doing nothing"
+    else
+        zle -M "$(mkdir -p -v "${PATHTOMKDIR}")"
+        zle end-of-line
+    fi
+}
+zle -N _inplaceMkDirs && bindkey '^xm' _inplaceMkDirs