diff --git a/.config/scripts/functions/fzf b/.config/scripts/functions/fzf new file mode 100644 index 0000000..7b2b84b --- /dev/null +++ b/.config/scripts/functions/fzf @@ -0,0 +1,30 @@ +#!/bin/bash +# +# These are functions related to fzf used to go to locations, edit +# configurations, or start a tmux session in common directories. + +# Finds within current directory and cd into the location of the file or +# directory. +goto() +{ + path=$(find $1 | fzf) + [ -f "$path" ] && path=$(dirname "$path") + cd "$path" +} + +# Quickly find and edit a file within ~/.config or ~/Documents +cfg() +{ + file=$(find $HOME/.config $HOME/Documents -type f | fzf) + [ -z "$file" ] && return + $EDITOR "$file" +} + +# Quickly find a directory within ~/.config or ~/Documents and start a tmux +# session there with the name of the directory. +ts() +{ + dir=$(find $HOME/.config $HOME/Documents -type d | fzf) + [ -z "$dir" ] && return + tmux new -s $(basename "$dir") -c "$dir" +}