mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
feat: Updates tmux-sessionator to also create session properly when tmux isn't running.
This commit is contained in:
@@ -41,6 +41,15 @@ function setup_fuzzy_find_paths() {
|
|||||||
debug_print "paths: $paths"
|
debug_print "paths: $paths"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_session() {
|
||||||
|
local selected_name=$1
|
||||||
|
local selected=$2
|
||||||
|
|
||||||
|
tmux new-session -ds "$selected_name" -c "$selected" -n "editor"
|
||||||
|
tmux send-keys -t editor 'n' Enter
|
||||||
|
tmux new-window -d -n "terminal" -c "$selected"
|
||||||
|
}
|
||||||
|
|
||||||
#################### MAIN ####################
|
#################### MAIN ####################
|
||||||
|
|
||||||
declare choose="${chooseOpt[-1]}"
|
declare choose="${chooseOpt[-1]}"
|
||||||
@@ -83,16 +92,19 @@ selected_name=$(basename "$selected" | tr . _)
|
|||||||
tmux_running=$(pgrep tmux)
|
tmux_running=$(pgrep tmux)
|
||||||
|
|
||||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||||
tmux new-session -s "$selected_name" -c "$selected"
|
create_session "$selected_name" "$selected"
|
||||||
exit 0
|
# tmux new-session -s "$selected_name" -c "$selected"
|
||||||
|
# exit 0
|
||||||
|
elif ! tmux has-session -t "$selected_name" 2> /dev/null; then
|
||||||
|
create_session "$selected_name" "$selected"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a session if it doesn't exist.
|
# Create a session if it doesn't exist.
|
||||||
if ! tmux has-session -t "$selected_name" 2> /dev/null; then
|
# if ! tmux has-session -t "$selected_name" 2> /dev/null; then
|
||||||
tmux new-session -ds "$selected_name" -c "$selected" -n "editor"
|
# tmux new-session -ds "$selected_name" -c "$selected" -n "editor"
|
||||||
tmux send-keys -t editor 'n' Enter
|
# tmux send-keys -t editor 'n' Enter
|
||||||
tmux new-window -d -n "terminal" -c "$selected"
|
# tmux new-window -d -n "terminal" -c "$selected"
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
[ -z $TMUX ] && tmux attach -t "$selected_name" \
|
[ -z $TMUX ] && tmux attach -t "$selected_name" \
|
||||||
|| tmux switch-client -t "$selected_name"
|
|| tmux switch-client -t "$selected_name"
|
||||||
|
|||||||
Reference in New Issue
Block a user