dotfiles/modules/programs/tmux/tmux-sessionizer/script.fish

21 lines
530 B
Fish
Raw Normal View History

2023-10-04 15:02:27 +02:00
set pipe (mktemp --dry-run)
mkfifo $pipe
fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | tee $pipe >/dev/null &
fd . ~/ --min-depth 1 --max-depth 3 --type d | tee $pipe >/dev/null &
set selected (cat $pipe | fzf $argv)
rm -f "$pipe"
2023-07-04 11:44:55 +02:00
set selected_name (basename $selected 2>/dev/null | string replace "." "_")
if not test -n "$selected_name"
exit 1
end
if ! tmux has-session -t $selected_name 2> /dev/null
tmux new-session -ds $selected_name -c $selected
end
tmux-switch $selected_name