summaryrefslogtreecommitdiff
path: root/fedora/.local/bin/tmuxcreate
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-07 18:16:05 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-07 18:16:05 +0900
commit5ff02959d3069923bca63cb54c4bb246b86bf20d (patch)
tree7ef1b56fb85a48c563bb3af51c26f181741282be /fedora/.local/bin/tmuxcreate
parentf65fe7591c18d6c8f4ecac5f379407a910aba1bc (diff)
deleted .gnupg/gpg-agent.conf, created .gnupg/, created .config/, created .local/, created .gnupg/
Diffstat (limited to 'fedora/.local/bin/tmuxcreate')
-rwxr-xr-xfedora/.local/bin/tmuxcreate42
1 files changed, 42 insertions, 0 deletions
diff --git a/fedora/.local/bin/tmuxcreate b/fedora/.local/bin/tmuxcreate
new file mode 100755
index 0000000..5fb5ef3
--- /dev/null
+++ b/fedora/.local/bin/tmuxcreate
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+create_new_session() {
+ session_name=$1
+ session_path=${2:-"$PWD"} # Default to current directory if no path is provided
+ [ -z "$session_name" ] && { printf "New session name: " && read -r session_name; }
+ if tmux has-session -t "$session_name" 2>/dev/null; then
+ tmux switch-client -t "$session_name"
+ else
+ if [ -n "$TMUX" ]; then
+ tmux new-session -d -s "$session_name" -c "$session_path"
+ tmux switch-client -t "$session_name"
+ else
+ tmux new -s "$session_name" -c "$session_path"
+ fi
+ fi
+}
+
+if [ $# -gt 0 ]; then
+ if [ -d "$1" ]; then
+ create_new_session "$(basename "$1")" "$1"
+ else
+ create_new_session "$1"
+ fi
+else
+ # Capture the output of tmux ls
+ sessions=$(tmux ls 2>/dev/null)
+ if [ -z "$sessions" ]; then
+ create_new_session
+ else
+ session=$( (
+ echo "$sessions"
+ echo "[new session]"
+ ) | fzf-tmux --reverse | cut -d: -f1)
+ [ -z "$session" ] && exit
+ if [ "$session" = "[new session]" ]; then
+ create_new_session
+ else
+ tmux attach -t "$session"
+ fi
+ fi
+fi