From 31a0cb1a9f2096613f95e15fd69fef0625391635 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 4 Oct 2025 12:09:23 +0200 Subject: [PATCH] Make shit hardcodable in oneshot --- tmux-oneshot.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tmux-oneshot.sh b/tmux-oneshot.sh index 28e424b..ed4a705 100644 --- a/tmux-oneshot.sh +++ b/tmux-oneshot.sh @@ -2,6 +2,11 @@ # tmux-oneshot.sh # Run a single command in a tmux session +# Hardcoded command and settings (uncomment and modify as needed) +# SESSION="mytest" +# COMMAND="ping google.com" +# ATTACH_SESSION=1 + SESSION="" ATTACH_SESSION=0 @@ -15,15 +20,20 @@ while getopts "t:a" opt; do done shift $((OPTIND-1)) +# Use hardcoded command if no arguments provided if [ $# -eq 0 ]; then - echo "Error: Command is required" >&2 - echo "Usage: $0 [-t ] [-a] " >&2 - exit 1 + if [ -n "$COMMAND" ]; then + echo "Using hardcoded command: $COMMAND" + else + echo "Error: Command is required" >&2 + echo "Usage: $0 [-t ] [-a] " >&2 + exit 1 + fi +else + COMMAND="$*" fi -COMMAND="$*" - -# Use first word of command as session name if -t not provided +# Use hardcoded session name, or first word of command if not provided if [ -z "$SESSION" ]; then SESSION=$(echo "$COMMAND" | awk '{print $1}') fi