summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2014-03-20 01:57:57 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2014-03-20 01:57:57 +0900
commitf02bb4fdac691dda6fff0c0e97441aa0d814b72c (patch)
tree4bf7c4f6cd78dd2d4f78309d805933aae03ca2ef
parent0a8352a5cdb7346b7d73ecc1b0259681c94450e0 (diff)
downloadfzf-f02bb4fdac691dda6fff0c0e97441aa0d814b72c.tar.gz
Add `fe` command to examples section as suggested in #27
-rw-r--r--README.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/README.md b/README.md
index 497c0bdd..259ed69d 100644
--- a/README.md
+++ b/README.md
@@ -176,6 +176,29 @@ fco() {
commit=$(echo "$commits" | fzf +s +m -e) &&
git checkout $(echo "$commit" | sed "s/ .*//")
}
+
+# fq1 [QUERY]
+# - Immediately select the file when there's only one match.
+# If not, start the fuzzy finder as usual.
+fq1() {
+ local lines
+ lines=$(fzf --filter="$1" --no-sort)
+ if [ -z "$lines" ]; then
+ return 1
+ elif [ $(wc -l <<< "$lines") -eq 1 ]; then
+ echo "$lines"
+ else
+ echo "$lines" | fzf --query="$1"
+ fi
+}
+
+# fe [QUERY]
+# - Open the selected file with the default editor
+# (Bypass fuzzy finder when there's only one match)
+fe() {
+ local file
+ file=$(fq1 "$1") && ${EDITOR:-vim} "$file"
+}
```
Key bindings for command line