Added fzf functions.

This commit is contained in:
Sheldon Lee 2022-11-18 20:17:48 +00:00
parent 2c9ff2a6a6
commit 3bffa00e0a

View File

@ -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"
}