lists your git workspaces and opens a new tmux session for the selected folder or switches if a session already exists for the workspace
ThePrimeagen
- adjust "max_depth" to your preference. the higher the value the slower results will appear.
#!/usr/bin/env bash
base_dir="$HOME/FOLDER_WHERE_YOUR_GIT_REPOS_ARE"
max_depth=3
selected=$(find $base_dir -mindepth 1 -maxdepth $max_depth -name .git -type d | sed 's/\/\.git$//' | fzf)
if [[ -z $selected ]]; then
exit 0
fi
selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $selected_name -c $selected
exit 0
fi
if ! tmux has-session -t=$selected_name 2> /dev/null; then
tmux new-session -ds $selected_name -c $selected
fi
tmux switch-client -t $selected_name
based on sessionizer. lists all your git repositories in fzf to open on current shell and if in tmux, it renames the window.
renxzen
- adjust "max_depth" to your preference. the higher the value the slower results will appear.
#!/usr/bin/env bash
base_dir="$HOME/FOLDER_WHERE_YOUR_GIT_REPOS_ARE"
max_depth=3
selected=$(find $base_dir -mindepth 1 -maxdepth $max_depth -name .git -type d -prune | sed 's/\/\.git$//' | fzf --prompt="Select git folder:")
if [[ -z $selected ]]; then
exit 0
fi
selected_name=$(basename -- "$selected" | tr . _)
cd $selected
if [ -n "$TMUX" ]; then
tmux rename-window $selected_name
fi
lists your tmux sessions in fzf and switches to selected
renxzen
#!/bin/bash
selected_session=$(tmux list-sessions -F "#S" | fzf --prompt="Select tmux session:")
if [ -n "$selected_session" ]; then
tmux switch-client -t "$selected_session"
fi
- make sure the scripts are in your path
- append to ~/.tmux.conf
bind e new-window -n (sessionizer) 'source tmux-sessionizer; exit; zsh'
bind r new-window -n (repositories) 'source repositories; zsh'
bind f new-window -n (switcher) 'source tmux-switcher; exit; zsh'