Skip to content

MainWindow: Use the XTerm title if defined - #602

Merged
jeremypw merged 5 commits into
masterfrom
xterm-title
Sep 7, 2021
Merged

jeremypw merged 5 commits into
masterfrom
xterm-title

Conversation

@Marukesu

Copy link
Copy Markdown
Contributor

re-enable the use of window_title if there's a defined title. if the title is empty, we fallback to the current directory for tabs and set the title with TerminalWidget.DEFAULT_LABEL

closes #593

@jeremypw jeremypw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR causes a regression in showing the path as the window title under normal conditions.

I've added suggestions as to how to fix this. I am not sure whether you need to check whether current_working_directory is something valid but it is probably safer to test this and use TerminalWidget.DEFAULT_LABEL as an ultimate fallback.

Comment thread src/MainWindow.vala Outdated
Comment on lines +966 to +967
title = current_terminal.window_title != "" ? current_terminal.window_title
: TerminalWidget.DEFAULT_LABEL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to show the path in as the window title, if not overridden.

Suggested change
title = current_terminal.window_title != "" ? current_terminal.window_title
: TerminalWidget.DEFAULT_LABEL;
title = current_terminal.window_title != "" ? current_terminal.window_title
: current_terminal.current_working_directory;

Comment thread src/MainWindow.vala Outdated
Comment on lines +1496 to +1497
title = current_terminal.window_title != "" ? current_terminal.window_title
: TerminalWidget.DEFAULT_LABEL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to show the path in as the window title, if not overridden.

Suggested change
title = current_terminal.window_title != "" ? current_terminal.window_title
: TerminalWidget.DEFAULT_LABEL;
title = current_terminal.window_title != "" ? current_terminal.window_title
: current_terminal.current_working_directory;

Comment thread src/MainWindow.vala Outdated
Comment on lines +1469 to +1470
string term_label = terminal.window_title != "" ? terminal.window_title
: Path.get_basename (term_path);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes a regression when there isn't a custom prompt set in .bashrc. In that case the terminal label is the same as the terminal prompt (and window title) which is not what is wanted. The label should always show the terminal path (disambiguated).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's because .bashrc set a title by default:

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

elementary use a patch to set the title as dir: last_cmd or actual_cmd, see: https://github.com/elementary/os-patches/blob/712e7a310b32c205fde0c73025c54f1be9181e3e/debian/skel.bashrc#L114-L171

Comment thread src/MainWindow.vala Outdated
Comment on lines +1482 to +1483
string term2_name = terminal2.window_title != "" ? terminal2.window_title
: Path.get_basename (term2_path);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment re tab label regression.

@Marukesu
Marukesu requested a review from jeremypw June 25, 2021 19:38
@jeremypw

Copy link
Copy Markdown
Collaborator

@Marukesu You do not seem to have fixed the tab label regression when no custom prompt?

@Marukesu

Copy link
Copy Markdown
Contributor Author

You do not seem to have fixed the tab label regression when no custom prompt?

I think i misunderstand you review. as i said before, the window_title is the same of the prompt because .bashrc set both the same by default, and i don't think it's a regression but what this PR do (use a xterm title if we have one). However, if it was about the label and title be the same, i can update the PR fixing that.

@jeremypw

jeremypw commented Jul 5, 2021

Copy link
Copy Markdown
Collaborator

However, if it was about the label and title be the same, i can update the PR fixing that.

This PR should only change the appearance of Terminal sufficient only to fix the linked issue - that is the setting a custom window title from the command-line. It should not change the appearance in any other way. If you feel Terminal behaves incorrectly in another way then you should raise another issue about that. You are right that Terminal does not show tab labels the same way as e.g. Mate Terminal but that is, I think, by design.

@Marukesu

Marukesu commented Jul 5, 2021

Copy link
Copy Markdown
Contributor Author

This PR should only change the appearance of Terminal sufficient only to fix the linked issue - that is the setting a custom window title from the command-line.

i did it this way because was how it worked before #584 when there was a title.

@jeremypw

jeremypw commented Sep 7, 2021

Copy link
Copy Markdown
Collaborator

@Marukesu Sorry for the delay in re-reviewing. I think this is now acceptable subject to resolution of the conflicts.

@jeremypw

jeremypw commented Sep 7, 2021

Copy link
Copy Markdown
Collaborator

Note: I had to use echo -ne '\033]2;this works\007' to get the title to change - your issue did not use the -e flag - perhaps your shell is different?

@Marukesu

Marukesu commented Sep 7, 2021

Copy link
Copy Markdown
Contributor Author

Note: I had to use echo -ne '\033]2;this works\007' to get the title to change - your issue did not use the -e flag - perhaps your shell is different?

Yeah, I'm using zsh and echo apply the escape characters automatically here, while bash needs the -e flag for that.

@jeremypw jeremypw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows setting window title from commandline without affecting tab labelling. Thanks!

@jeremypw
jeremypw merged commit 32e4e29 into master Sep 7, 2021
@jeremypw
jeremypw deleted the xterm-title branch September 7, 2021 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot Set Custom XTerm Title

2 participants