#!/usr/bin/env bash
IFS=$'\n' out=("$(fzf-tmux --query="$1" --exit-0 --expect=ctrl-o,ctrl-e)")
key=$(head -1 <<< "$out")
file=$(head -2 <<< "$out" | tail -1)
if [ -n "$file" ]; then
  [ "$key" = ctrl-o ] && open "$file" || ${EDITOR:-vim} "$file"
fi
