Skip to content

Instantly share code, notes, and snippets.

@acikgozb
Last active March 24, 2024 16:23
Show Gist options
  • Save acikgozb/d17794d3c1fffe0687874912b7d76770 to your computer and use it in GitHub Desktop.
Save acikgozb/d17794d3c1fffe0687874912b7d76770 to your computer and use it in GitHub Desktop.
tmux-window.sh
#!/usr/bin/env bash
if [[ -z "$TMUX_PANE" ]]; then
echo "not in a tmux session"
fi
session_name=$(tmux list-panes -t "$TMUX_PANE" -F '#S' | head -n1)
if [[ $session_name == "personal" ]]; then
path_to_search="$HOME/personal"
else
path_to_search="$HOME/work"
fi
window_path=$(fd . $path_to_search --hidden --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 zsh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment