m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-20 09:33:42 -05:00

fe with ctrl-o

Junegunn Choi
2015-04-05 02:56:35 +09:00
parent 9214986dcc
commit a9f3a5ee94

@@ -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
}
```