Last active
March 24, 2024 16:23
-
-
Save acikgozb/d17794d3c1fffe0687874912b7d76770 to your computer and use it in GitHub Desktop.
tmux-window.sh
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 | |
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