Skip to content

Instantly share code, notes, and snippets.

@acikgozb
Last active January 31, 2025 23:01
Fuzzy find directories under $HOME/<tmux_session_name> to open them in a new tmux window.
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "$TMUX_PANE" ]]; then
echo "not in a tmux session" >&2
exit 1
fi
session_name=$(tmux list-panes -t "$TMUX_PANE" -F '#S' | head -n1)
path_to_search="$HOME/$session_name"
window_path=$(fd . "$path_to_search" --hidden -d 1 --type d | fzf)
window_name=$(echo "$window_path" | awk -F "/" '{ if ($NF==""){print $(NF-1)}; if($NF!=""){print $NF} }')
tmux new-window -t "$session_name" -n "$window_name" "cd $window_path; exec $SHELL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment