screen init output run update

This commit is contained in:
Clemens Schwaighofer
2025-05-30 09:47:16 +09:00
parent e068a6c659
commit 369dcb7329

View File

@@ -81,16 +81,16 @@ do
# should I clean the title to alphanumeric? (well yes, but not now) # should I clean the title to alphanumeric? (well yes, but not now)
SCREEN_NAME=$line; SCREEN_NAME=$line;
if [ -z "$SCREEN_NAME" ]; then if [ -z "$SCREEN_NAME" ]; then
echo "No screen name set"; echo "[!] No screen name set";
exit; exit;
fi; fi;
if [[ ! $SCREEN_NAME =~ ^[A-Za-z0-9]+$ ]]; then if [[ ! $SCREEN_NAME =~ ^[A-Za-z0-9]+$ ]]; then
echo "Screen name must be alphanumeric: ${SCREEN_NAME}"; echo "[!] Screen name must be alphanumeric: ${SCREEN_NAME}";
exit; exit;
fi; fi;
# check that we do not create double entries # check that we do not create double entries
if screen -list | grep -q "${SCREEN_NAME}"; then if screen -list | grep -q "${SCREEN_NAME}"; then
echo "Screen with ${SCREEN_NAME} already exists"; echo "[!] Screen with ${SCREEN_NAME} already exists";
exit; exit;
fi; fi;
else else
@@ -101,7 +101,7 @@ do
SCREEN_CMD=$(echo "$line" | cut -d "#" -f 2); SCREEN_CMD=$(echo "$line" | cut -d "#" -f 2);
# skip lines that start with ";" these are comments, we do not use # as they are separators # skip lines that start with ";" these are comments, we do not use # as they are separators
if [[ $line =~ ^\; ]]; then if [[ $line =~ ^\; ]]; then
echo "[SKIP] [$SCREEN_POS] '${SCREEN_TITLE}' with command '${SCREEN_CMD}'"; printf "[%>2s] [SKIP] '%s' with command '%s'" $SCREEN_POS "$SCREEN_TITLE" "$SCREEN_CMD";
continue; continue;
fi; fi;
# skip empty lines # skip empty lines
@@ -111,17 +111,17 @@ do
# for the first screen, we need to init the screen and only set title # for the first screen, we need to init the screen and only set title
# for the rest we set a new screen with title # for the rest we set a new screen with title
if [ $pos -eq 1 ]; then if [ $pos -eq 1 ]; then
echo "Init screen with title '$SCREEN_NAME'"; printf " * INIT screen with title '%s'" "$SCREEN_NAME";
screen -dmS "$SCREEN_NAME"; screen -dmS "$SCREEN_NAME";
# set title for the first # set title for the first
screen -r "$SCREEN_NAME" -p $SCREEN_POS -X title "$SCREEN_TITLE"; screen -r "$SCREEN_NAME" -p $SCREEN_POS -X title "$SCREEN_TITLE";
else else
screen -r "$SCREEN_NAME" -X screen -t "$SCREEN_TITLE" $SCREEN_POS; screen -r "$SCREEN_NAME" -X screen -t "$SCREEN_TITLE" $SCREEN_POS;
fi; fi;
echo "[$SCREEN_POS] + Set title to '$SCREEN_TITLE'"; printf "[%>2s] + ADD window with title '%s'" $SCREEN_POS "$SCREEN_TITLE";
# run command on it (if there is one) # run command on it (if there is one)
if [ -n "$SCREEN_CMD" ]; then if [ -n "$SCREEN_CMD" ]; then
echo "[$SCREEN_POS] > Run command '$SCREEN_CMD'"; printf " > RUN command to '%s'" $SCREEN_POS "$SCREEN_CMD";
# if ^M is garbled: in vim do: i, ^V, ENTER, ESCAPE # if ^M is garbled: in vim do: i, ^V, ENTER, ESCAPE
screen -r "$SCREEN_NAME" -p $SCREEN_POS -X stuff $"$SCREEN_CMD^M"; screen -r "$SCREEN_NAME" -p $SCREEN_POS -X stuff $"$SCREEN_CMD^M";
fi; fi;