Make shit hardcodable in oneshot

This commit is contained in:
2025-10-04 12:09:23 +02:00
parent 2feb9847be
commit 31a0cb1a9f

View File

@@ -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
if [ -n "$COMMAND" ]; then
echo "Using hardcoded command: $COMMAND"
else
echo "Error: Command is required" >&2
echo "Usage: $0 [-t <session_name>] [-a] <command>" >&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