Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env bash
set -e
main() {
previous_file="$1"
file_to_edit=`select_file $previous_file`
if [ -n "$file_to_edit" ] ; then
"$EDITOR" "$file_to_edit"
main "$file_to_edit"
fi
}
select_file() {
given_file="$1"
fzf --preview="cat {}" --preview-window=right:70%:wrap --query="$given_file"
}
main ""
@BaseCase

This comment has been minimized.

Copy link
Owner Author

BaseCase commented Sep 19, 2017

My little note-taking thing using fzf. Here's a blog post where I explain it.

@echorebel

This comment has been minimized.

Copy link

echorebel commented Jan 23, 2019

cool

@deefin

This comment has been minimized.

Copy link

deefin commented Mar 13, 2019

#!/usr/bin/env bash
set -e

main() {
  cd $HOME/notes
  previous_file="$1"
  file_to_edit=`select_file $previous_file`

  if [ -n "$file_to_edit" ] ; then
    "$EDITOR" "$file_to_edit"
    main "$file_to_edit"
  fi
  cd -
}

select_file() {
  given_file="$1"
  fzf --preview="cat {}" --preview-window=right:70%:wrap --query="$given_file"
}

main ""

Add the two CD commands to wrap around the main func so you could call this from anywhere and have fzf only ever index the $HOME/notes dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.