From 5f48daf97b5707945e73d0a2e1cd467a29d19537 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 2 May 2014 07:45:28 -0700 Subject: [PATCH] Updated examples (markdown) --- examples.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/examples.md b/examples.md index f7898e0..5988351 100644 --- a/examples.md +++ b/examples.md @@ -3,8 +3,8 @@ Useful examples Feel free to edit this page if you have a nice example of using fzf. -Opening files and directories ------------------------------ +Opening files +------------- ```sh # fe [FUZZY PATTERN] - Open the selected file with the default editor @@ -17,6 +17,9 @@ fe() { } ``` +Changing directory +------------------ + ```sh # fd - cd to selected directory fd() { @@ -35,6 +38,17 @@ fda() { } ``` +Suggested by @harelba and @dimonomid: + +```sh +# cdf - cd into the directory of the selected file +cdf() { + local file + local dir + file=$(fzf +m -q "$1") && dir=$(dirname "$file") && cd "$dir" +} +``` + Command history ---------------