-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small fix to tmux sessionizer from ThePrimeagen/.dotfiles#32
- Loading branch information
1 parent
679a235
commit a7b0e11
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ $# -eq 1 ]]; then | ||
selected=$1 | ||
else | ||
selected=$(find ~/work ~/personal/projects/ -mindepth 1 -maxdepth 1 -type d | fzf) | ||
fi | ||
|
||
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 | ||
|
||
if [[ -z $TMUX ]]; then | ||
tmux attach-session -t $selected_name | ||
else | ||
tmux switch-client -t $selected_name | ||
fi |