tm
"/home/yossef/notes/git/scripts/tm.md"
path: git/scripts/tm.md
- **fileName**: tm
- **Created on**: 2025-03-26 14:27:50
scripts using a fzf for search for folder from my base dir /home/yossef
and then if found this dir change to this dir and open tmux session in this dir
install some dependence tmux, fzf
arch : sudo pacman -S tmux fzf
popos : sudo apt install tmux fzf
#!/bin/sh
tm() {
# check here if the session is already open switch to this session
if [ -z "$1" ]; then
tmux switch-client -l
else
# starting creatting the session
dir_path="$1"
dir_name=$(basename "$dir_path")
if [ -z "$TMUX" ]; then
tmux new-session -As "$dir_name" -c "$dir_path"
else
if ! tmux has-session -t "$dir_name" 2>/dev/null; then
tmux new-session -ds "$dir_name" -c "$dir_path"
fi
tmux switch-client -t "$dir_name"
fi
fi
}
# Use fzf to select a directory with error handling
selected_dir=$(find ~ -type d 2>/dev/null | fzf)
# Check if a directory was selected
if [ -n "$selected_dir" ]; then
tm "$selected_dir"
else
echo "No directory selected."
fi
continue:./fcd.md
before:./nvim_switcher.md