Skip to content

Instantly share code, notes, and snippets.

@wphicks
Created May 14, 2018 11:42
Show Gist options
  • Save wphicks/94900259f7549049c742d9e27cd7c16c to your computer and use it in GitHub Desktop.
Save wphicks/94900259f7549049c742d9e27cd7c16c to your computer and use it in GitHub Desktop.
Convenient note-taking functions with fzf
function ff() {
if [ -z $1 ]
then
search_dir="."
else
search_dir="$1"
fi
ag --nobreak --noheading . $search_dir | \
fzf --preview='cat "$(echo {} | cut -d: -f1)"' --preview-window=right
}
function nn () {
if [ -z $1 ]
then
search_dir="$HOME/.vimwiki"
else
search_dir="$1"
fi
pushd $searchdir > /dev/null
file_to_edit=`ff "$search_dir"`
line_number=`echo "$file_to_edit" | cut -d: -f2`
file_to_edit=`echo "$file_to_edit" | cut -d: -f1`
if [ -n "$file_to_edit" ]
then
vim "+$line_number" "$file_to_edit"
nn
fi
popd > /dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment