Krolyxon
Commit 8aad227

Branches

Refs →

aurora.localbintms

25 lines · 551 B · Bourne Again Shell (bash)

1#!/bin/env bash
2
3if [[ $# -eq 1 ]]; then
4 selected=$1;
5else
6 selected=$(find ~/code/dev ~/code/repos ~/code/rust -mindepth 1 -maxdepth 1 -type d | fzf);
7fi
8
9if [[ -z $selected ]]; then
10 exit 0
11fi
12
13selected_name=$(basename "$selected" | tr . _)
14tmux_running=$(pgrep tmux)
15
16if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
17 tmux new-session -s $selected_name -c $selected
18 exit 0
19fi
20
21if ! tmux has-session -t=$selected_name 2> /dev/null; then
22 tmux new-session -ds $selected_name -c $selected
23fi
24
25tmux switch-client -t $selected_name