From a9f3a5ee949d68fa1e45fe67529212358820b258 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 5 Apr 2015 02:56:35 +0900 Subject: [PATCH] fe with ctrl-o --- Examples.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Examples.md b/Examples.md index 439c747..fc1ac4e 100644 --- a/Examples.md +++ b/Examples.md @@ -12,11 +12,16 @@ fe() { [ -n "$file" ] && ${EDITOR:-vim} "$file" } -# Equivalent to above, but opens it with `open` command -fo() { - local file - file=$(fzf --query="$1" --select-1 --exit-0) - [ -n "$file" ] && open "$file" +# Extended version where you can press CTRL-O to open with `open` command +# fe [FUZZY PATTERN] +fe() { + local out file key + out=$(fzf-tmux --query="$1" --exit-0 --expect=ctrl-o) + key=$(head -1 <<< "$out") + file=$(head -2 <<< "$out" | tail -1) + if [ -n "$file" ]; then + [ "$key" = ctrl-o ] && open "$file" || ${EDITOR:-vim} "$file" + fi } ```