mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-16 23:33:39 -05:00
Use parentheses instead of braces not to affect IFS (#1859)
10
Examples.md
10
Examples.md
@@ -100,24 +100,22 @@ ec () {
|
|||||||
# fe [FUZZY PATTERN] - Open the selected file with the default editor
|
# fe [FUZZY PATTERN] - Open the selected file with the default editor
|
||||||
# - Bypass fuzzy finder if there's only one match (--select-1)
|
# - Bypass fuzzy finder if there's only one match (--select-1)
|
||||||
# - Exit if there's no match (--exit-0)
|
# - Exit if there's no match (--exit-0)
|
||||||
fe() {
|
fe() (
|
||||||
local files
|
|
||||||
IFS=$'\n' files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
|
IFS=$'\n' files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
|
||||||
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
|
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
|
||||||
}
|
)
|
||||||
|
|
||||||
# Modified version where you can press
|
# Modified version where you can press
|
||||||
# - CTRL-O to open with `open` command,
|
# - CTRL-O to open with `open` command,
|
||||||
# - CTRL-E or Enter key to open with the $EDITOR
|
# - CTRL-E or Enter key to open with the $EDITOR
|
||||||
fo() {
|
fo() (
|
||||||
local out file key
|
|
||||||
IFS=$'\n' out=("$(fzf-tmux --query="$1" --exit-0 --expect=ctrl-o,ctrl-e)")
|
IFS=$'\n' out=("$(fzf-tmux --query="$1" --exit-0 --expect=ctrl-o,ctrl-e)")
|
||||||
key=$(head -1 <<< "$out")
|
key=$(head -1 <<< "$out")
|
||||||
file=$(head -2 <<< "$out" | tail -1)
|
file=$(head -2 <<< "$out" | tail -1)
|
||||||
if [ -n "$file" ]; then
|
if [ -n "$file" ]; then
|
||||||
[ "$key" = ctrl-o ] && open "$file" || ${EDITOR:-vim} "$file"
|
[ "$key" = ctrl-o ] && open "$file" || ${EDITOR:-vim} "$file"
|
||||||
fi
|
fi
|
||||||
}
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
Reference in New Issue
Block a user