1. Takafumi Arakaki
  2. zaw-sources

Source

zaw-sources / zaw-mendeley.zsh

# -*- sh -*-
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:; :)@}\""
}