#!/bin/bash # # These are functions related to fzf used to go to locations, edit # configurations, or start a tmux session in common directories. # Finds recursively within current directory and cd into the location of the # file or directory. goto() { path=$(find $1 2> /dev/null | fzf) [ -f "$path" ] && path=$(dirname "$path") cd "$path" } # Finds files recursively within current directory and edits file. edit() { file=$(find $1 -type f 2> /dev/null | fzf) [ -z "$file" ] && return $EDITOR "$file" } # Quickly find and edit a file within ~/.config or ~/Documents cfg() { file=$(find $HOME/.config $HOME/Documents -type f 2> /dev/null | 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 -L $HOME/Documents -type d 2> /dev/null | fzf) [ -z "$dir" ] && return tmux new -s $(basename "$dir") -c "$dir" }