1. Takafumi Arakaki
  2. zaw-sources

Commits

Takafumi Arakaki  committed d0267bb

added zaw-{gisty,mendeley,z}.zsh

  • Participants
  • Branches default

Comments (0)

Files changed (3)

File zaw-gisty.zsh

View file
+zmodload zsh/parameter
+
+function zaw-src-gisty() {
+    candidates=("${(ps:\n:)$(gisty list)}")
+    actions=("zaw-callback-gisty-append-to-buffer")
+    act_descriptions=("append to edit buffer")
+}
+
+zaw-register-src -n gisty zaw-src-gisty
+
+function zaw-callback-gisty-append-to-buffer() {
+    local gitdir=`echo "${(j:; :)@}" | cut -d":" -f1`
+    local destpath=$GISTY_DIR/$gitdir
+    if [ -n "$gitdir" -a -d "$destpath" ]
+    then
+        LBUFFER="${BUFFER}${destpath}"
+    fi
+}

File zaw-mendeley.zsh

View file
+zmodload zsh/parameter
+
+function zaw-src-mendeley() {
+    candidates=("${(ps:\n:)$(ls $ZAW_MENDELEY_DIR)}")
+    actions=("zaw-callback-mendeley-open" "zaw-callback-mendeley-append-to-buffer")
+    act_descriptions=("open mendeley document" "append to edit buffer")
+}
+
+zaw-register-src -n mendeley zaw-src-mendeley
+
+export ZAW_MENDELEY_DIR="$HOME/Documents/Mendeley Desktop"
+export ZAW_MENDELEY_OPEN=gnome-open
+
+function zaw-callback-mendeley-open() {
+    local orig_buffer="${BUFFER}"
+    BUFFER="${ZAW_MENDELEY_OPEN} \"${ZAW_MENDELEY_DIR}/${(j:; :)@}\""
+    zle accept-line
+}
+
+function zaw-callback-mendeley-append-to-buffer() {
+    LBUFFER="${BUFFER}\"${ZAW_MENDELEY_DIR}/${(j:; :)@}\""
+}

File zaw-z.zsh

View file
+zmodload zsh/parameter
+
+function zaw-src-z() {
+    : ${(A)candidates::=`z 2>&1 | sed -n -e '2,$p' | sed 's/^[0-9\\. ]*//' | tac`}
+    actions=("zaw-callback-execute" "zaw-callback-replace-buffer" "zaw-callback-append-to-buffer")
+    act_descriptions=("execute" "replace edit buffer" "append to edit buffer")
+}
+
+zaw-register-src -n z zaw-src-z