From 5423cd1bd1bc32cbcab67c37a76737b8576c5a1c Mon Sep 17 00:00:00 2001 From: thek4n Date: Sun, 13 Oct 2024 23:51:10 +0300 Subject: [PATCH] tmux session managment fix --- .gitignore | 7 ++++--- home/user/.tmux/dotfiles.sh | 18 ++++++++++++++++++ home/user/.tmux/temp.sh | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100755 home/user/.tmux/dotfiles.sh create mode 100755 home/user/.tmux/temp.sh diff --git a/.gitignore b/.gitignore index 5625516..acef7ab 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ home/user/.termux/shell home/user/.config/tmux/plugins home/user/.config/tmux/local.conf -home/user/.tmux/* -!home/user/.tmux/01.sh -!home/user/.tmux/10.sh + +!home/user/.tmux/* +!home/user/.tmux/dotfiles.sh +!home/user/.tmux/temp.sh \ No newline at end of file diff --git a/home/user/.tmux/dotfiles.sh b/home/user/.tmux/dotfiles.sh new file mode 100755 index 0000000..b4c077f --- /dev/null +++ b/home/user/.tmux/dotfiles.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -x + +SESSION=dotfiles +MAINW=1 + +WORKING_PROJECT="$HOME/dotfiles" + +if ! tmux has-session -t "$SESSION"; then + tmux new-session -s "$SESSION" -d -n "$MAINW" -c "$WORKING_PROJECT" + tmux splitw -t "$SESSION:$MAINW" -d -b -h -l "$_tmux_other_pane_size" -c '#{pane_current_path}' + tmux send-keys -t "$SESSION:$MAINW.1" "git pull && git push" Enter + tmux send-keys -t "$SESSION:$MAINW.2" '$EDITOR' Enter + tmux send-keys -t "$SESSION:$MAINW.2" ':Telescope find_files' Enter +fi + +tmux switch-client -t "$SESSION" \ No newline at end of file diff --git a/home/user/.tmux/temp.sh b/home/user/.tmux/temp.sh new file mode 100755 index 0000000..06fbaee --- /dev/null +++ b/home/user/.tmux/temp.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -x + +readonly RND="${RANDOM}" +readonly SESSION="sandbox${RND}" + + +declare WORKING_PROJECT +WORKING_PROJECT="$(mktemp -td "sandbox${RND}.XXXX")" +readonly WORKING_PROJECT + +tmux new-session -s "${SESSION}" -d -c "${WORKING_PROJECT}" +tmux switch-client -t "${SESSION}" \ No newline at end of file