Takafumi Arakaki avatar Takafumi Arakaki committed 16f69b6

added zaw-switch-editor.zsh

Comments (0)

Files changed (1)

zaw-switch-editor.zsh

+# -*- sh -*-
+zmodload zsh/parameter
+
+function zaw-src-switch-editor() {
+    candidates=("${(ps.:.)ZAW_SWITCH_EDITOR}")
+    actions=("zaw-callback-switch-editor-execute"
+        "zaw-callback-switch-editor-replace-buffer")
+    act_descriptions=("switch editor" "append to edit buffer")
+}
+
+zaw-register-src -n switch-editor zaw-src-switch-editor
+
+export ZAW_SWITCH_EDITOR="${EDITOR}:emacsclient:vim:jed:vi"
+
+function zaw-callback-switch-editor-execute() {
+    local orig_buffer="${BUFFER}"
+    BUFFER="export EDITOR='${(j:; :)@}'"
+    zle accept-line
+}
+
+function zaw-callback-switch-editor-replace-buffer() {
+    LBUFFER="export EDITOR='${(j:; :)@}'"
+    RBUFFER=""
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.