-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmx
More file actions
executable file
·24 lines (19 loc) · 710 Bytes
/
Copy pathtmx
File metadata and controls
executable file
·24 lines (19 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Use fzf to fuzzy find a directory from the file
selected_dir=$(zoxide query -l | fzf)
# Check if the selection is empty (user pressed ESC or didn't select anything)
if [ -z "$selected_dir" ]; then
echo "No directory selected. Exiting."
exit 0
fi
# Get the basename of the selected directory
session_name=$(basename "$selected_dir")
# Check if a tmux session with the same name already exists
if tmux has-session -t "$session_name" 2>/dev/null; then
# If the session already exists, attach to it
tmux attach-session -t "$session_name"
else
# If the session does not exist, create a new session in the selected directory
cd "$selected_dir"
tmux new-session -s "$session_name"
fi