From 41b2d2f32f7da48b0113ca65cbda4380c5c4590e Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Mon, 24 Mar 2025 18:22:17 -0400 Subject: session management --- modules/tmux/session-load.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 modules/tmux/session-load.sh (limited to 'modules/tmux/session-load.sh') diff --git a/modules/tmux/session-load.sh b/modules/tmux/session-load.sh new file mode 100644 index 0000000..509dabe --- /dev/null +++ b/modules/tmux/session-load.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# usage: to create a project/session, create a symlink in .projects to the working directory +# the name of the symlink is the name of the project + +# if there is no path specific, prompt via fzf +if [[ $# -eq 1 ]]; then + input=$1 +else + input=$(cd $HOME/.projects; find . -type l | sed 's/^\.\///' | fzf) +fi + +if [[ -z $input ]]; then + exit 0 +fi + +project_name=$input +project_path=$(readlink "$HOME/.projects/$project_name") + +if [[ -z $(pgrep tmux) ]]; then + tmux start-sever # blocking +fi + +if ! tmux has-session -t $project_name 2> /dev/null; then + tmux new -ds $project_name -c $project_dir +fi + +if ! [[ -f ${project_path}/Session.vim ]] then + $(cd $project_path; nvim --headless +Obsession +q >/dev/null 2>&1) +fi + +if [[ $TMUX ]]; then + tmux switch-client -t $project_name +else + tmux a -t $project_name +fi + -- cgit v1.2.3