feat: Updates tmux-sessionator to accept a directory option and updates tns function to use that option.

This commit is contained in:
2024-12-03 08:56:56 -05:00
parent 9e48ba0a77
commit 82341d87df
2 changed files with 16 additions and 33 deletions

View File

@@ -8,9 +8,11 @@ debug="${DEBUG}"
declare -a paths=()
declare chooseOpt=
declare -a directory=()
zparseopts -D -- \
{c,-choose}=chooseOpt
{c,-choose}=chooseOpt \
{d,-directory}:=directory
#################### Helpers ####################
@@ -42,6 +44,7 @@ function setup_fuzzy_find_paths() {
#################### MAIN ####################
declare choose="${chooseOpt[-1]}"
declare selected=
if [[ -n $choose ]]; then
debug_print "Choose from existing."
@@ -49,6 +52,14 @@ if [[ -n $choose ]]; then
tmux list-sessions -F \#S | gum filter \
--placeholder "Pick a session..."
)
elif [ ${#directory} -gt 0 ]; then
debug_print "Using directory option."
selected=${directory[-1]}
if [ "$selected" = "." ] || [ "$selected" = "" ]; then
selected="${PWD}"
fi
debug_print "Directory: $selected"
elif [[ "$#" -eq 1 ]]; then
debug_print "Using existing session: $1"
selected=$1