Last active
January 31, 2025 23:01
Fuzzy find directories under $HOME/<tmux_session_name> to open them in a new tmux window.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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