dotfiles/.config/scripts/functions/fzf
2022-11-18 20:17:48 +00:00

31 lines
755 B
Bash

#!/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"
}