diff --git a/bashrc.d/ZZZ_always_screen b/bashrc.d/ZZZ_always_screen index 4d97b9e..9c7a0e9 100644 --- a/bashrc.d/ZZZ_always_screen +++ b/bashrc.d/ZZZ_always_screen @@ -1,12 +1,18 @@ #!/bin/bash # Create a Screen session everytime, unless you don't want -if [ -n "$(which screen)" ]; then +screen_cmd=$(which screen) +if [ -n "${screen_cmd}" ]; then if [ -n "${STY}" ]; then session_name="${STY//[0-9]*\./}" echo "This is screen session '${session_name}'" - if [ -n "$(which xtitle)" ]; then - "$(which xtitle)" "${session_name}" + xtitle_cmd="$(which xtitle)" + if [ -n ${xtitle_cmd} ]; then + "${xtitle_cmd}" -q "${session_name}" + return_code=$? + if [ ${return_code} != 0 ]; then + echo "There was an error ${return_code} setting the title." + fi 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 @@ -14,12 +20,12 @@ if [ -n "$(which screen)" ]; then 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 - "$(which xtitle)" "${session_name}" + if [ -n ${xtitle_cmd} ]; then + "${xtitle_cmd}" -q "${session_name}" 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 - "$(which screen)" -t "${session_name}" -S "${session_name}" && exit + "${screen_cmd}" -t "${session_name}" -S "${session_name}" && exit else echo "Ok, I'll leave you alone without a session..." fi diff --git a/bashrc.d/title b/bashrc.d/title index fd5ffc9..f3a1f0d 100644 --- a/bashrc.d/title +++ b/bashrc.d/title @@ -1,5 +1,9 @@ #!/bin/bash -xtitle_cmd="$(which xtitle)" -if [ -n "${xtitle_cmd}" ]; then - "${xtitle_cmd}" -q "${USER}@$(hostname -s)" +if [ -z "${STY}" ]; then + xtitle_cmd="$(which xtitle)" + if [ -n "${xtitle_cmd}" ]; then + new_title="${USER}@$(hostname -s)" + echo "Setting title to ${new_title}" + "${xtitle_cmd}" -q "${USER}@$(hostname -s)" + fi fi \ No newline at end of file