I want to set the title of the current screen window (inside the screen session) via a bash command.
I know it can be done via C-a A, but that does not work directly as a shell command.
screen -t <mytitle> <args>
in the current window works, but it creates a new window. I want to rename the current window.
All the posts I saw either dealt with doing this outside a running screen session, or used the screen keybindings/commands.
Open your ~/.bashrc file in gedit
gedit ~/.bashrc
Add the following function at the end of the file.
# function to set terminal title
function settitle(){
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
fi
TITLE="\[\e]2;$*\a\]"
PS1=${ORIG}${TITLE}
}
Rerun the bashrc file to make changes effective in the current terminal. This won't be needed afterwards.
source ~/.bashrc
Now using the function rename the terminal name from the shell. From the shell type
settitle hello
This will name it hello.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With