about summary refs log tree commit diff
path: root/Functions/Zle/edit-command-line
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2000-05-10 13:32:23 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2000-05-10 13:32:23 +0000
commit50997c02b3109b025e54b8c9701d1767879f16cf (patch)
tree1acf76c9cb91d5a33a31dafeb5818347c55eb9d4 /Functions/Zle/edit-command-line
parent2da726eaf11773318ac06cc24fa21569cd2758c8 (diff)
downloadzsh-50997c02b3109b025e54b8c9701d1767879f16cf.tar.gz
zsh-50997c02b3109b025e54b8c9701d1767879f16cf.tar.xz
zsh-50997c02b3109b025e54b8c9701d1767879f16cf.zip
11299: edit-command-line zle widget
Diffstat (limited to 'Functions/Zle/edit-command-line')
-rw-r--r--Functions/Zle/edit-command-line18
1 files changed, 18 insertions, 0 deletions
diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
new file mode 100644
index 000000000..8019329bd
--- /dev/null
+++ b/Functions/Zle/edit-command-line
@@ -0,0 +1,18 @@
+# Edit the command line using your usual editor.
+# Binding this to 'v' in the vi command mode map,
+#   autoload edit-command-line
+#   zle -N edit-command-line
+#   bindkey -M vicmd v edit-command-line
+# will give ksh-like behaviour for that key.
+
+local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
+
+print $BUFFER >$tmpfile
+exec </dev/tty
+${VISUAL:-${EDITOR:-vi}} $tmpfile
+LBUFFER=
+RBUFFER=
+BUFFER=$(<$tmpfile)
+
+rm -f $tmpfile
+zle redisplay