2022-05-05 15:05:06 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# Create a Screen session everytime, unless you don't want
|
|
|
|
|
|
|
|
if [ -n "$(which screen)" ]; then
|
|
|
|
if [ -n "${STY}" ]; then
|
2022-06-07 07:43:03 +02:00
|
|
|
session_name="${STY//[0-9]*\./}"
|
|
|
|
echo "This is screen session '${session_name}'"
|
2022-05-06 09:03:51 +02:00
|
|
|
if [ -n "$(which xtitle)" ]; then
|
2022-05-07 11:18:35 +02:00
|
|
|
"$(which xtitle)" "${session_name}"
|
2022-05-06 09:03:51 +02:00
|
|
|
else
|
|
|
|
echo "xtitle is not installed so I can't update the title of the X window with the session name. Install it and the experience will be better)"
|
|
|
|
fi
|
2022-05-05 15:05:06 +02:00
|
|
|
else
|
|
|
|
echo "This is not a screen session, let's create one. Name of the session?"
|
|
|
|
read -r session_name
|
|
|
|
if [ -n "${session_name}" ] && [ "${session_name}" != "" ]; then
|
|
|
|
if [ -n "$(which xtitle)" ]; then
|
2022-05-07 11:18:35 +02:00
|
|
|
"$(which xtitle)" "${session_name}"
|
2022-05-05 15:05:06 +02:00
|
|
|
else
|
|
|
|
echo "xtitle is not installed so I can't update the title of the X window with the session name. Install it and the experience will be better)"
|
|
|
|
fi
|
2022-05-07 11:18:35 +02:00
|
|
|
"$(which screen)" -t "${session_name}" -S "${session_name}" && exit
|
2022-05-05 15:05:06 +02:00
|
|
|
else
|
|
|
|
echo "Ok, I'll leave you alone without a session..."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Screen is not installed. Install it so always_screen in your bashrc will work."
|
|
|
|
fi
|