Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customization of terminal title #302

Merged
merged 1 commit into from
Sep 25, 2020

Conversation

duncanbeevers
Copy link
Contributor

@duncanbeevers duncanbeevers commented Sep 20, 2020

Summary

Previously, geometry showed output in three locations:

  • GEOMETRY_PROMPT
  • GEOMETRY_RPROMPT
  • GEOMETRY_INFO

This PR adds two new display locations:

  • GEOMETRY_TITLE
  • GEOMETRY_RUNTITLE

Details

Geometry was already implicitly updating the terminal title.
This PR allows configuration of these locations through the same paradigm as drives the rest of geometry.

The original title-controlling functions; geometry::clear_title, and geometry::set_title ran with an implicit lifecycle.

Challenges

De-coloring

The biggest challenge with this PR was de-coloring the output of geometry plugins.
The deansi function included here is hand-rolled and worked with the handful of functions I tried out; includinggeometry_path,geometry_node, and geometry_hostname.

Limited testing

I've primarily developed/tested this in iTerm. It looks a little funny in Terminal.app

iTerm Terminal.app
2020-09-20 at 12 47 PM 2020-09-20 at 12 43 PM

No current command

This PR is a regression, since the currently-executing command is no longer exposed in the terminal title.
It seems simplest to expose it as a generic geometry function, like geometry_cmd or something, but it may only be useful when used in GEOMETRY_RUNTITLE.

@jedahan
Copy link
Member

jedahan commented Sep 25, 2020

Great idea! I'd be happy to merge with a few minor changes:

  • Add this feature to the changelog

  • Set the default runtitle to show the currently running command (with or without geometry_cmd as an external function, I am not sure it makes sense externally)

  • (optional) Think if there could be a better name for RUNTITLE, where better could mean more consistent with zsh naming of things. For example, CMDTITLE since it is precmd. I am happy to merge as RUNTITLE though.

@duncanbeevers
Copy link
Contributor Author

duncanbeevers commented Sep 25, 2020

@jedahan I pushed a change that adds a geometry_cmd internal function used for displaying the currently-executing / last-executed command.

I didn't find a nice way to restore the " @ " in between the command and PWD, like in the old baked-in term title.
I thought maybe there was a way to do it with geometry_echo.

Any suggestions here would be appreciated.

2020-09-25 at 9 24 AM

@jedahan
Copy link
Member

jedahan commented Sep 25, 2020

I am happy keeping it as is (no " @ ") - geometry::wrap uses GEOMETRY_SEPARATOR, which is more consistent with the other output

Add GEOMETRY_TITLE and GEOMETRY_CMDTITLE display locations.
Geometry was already controlling the terminal title. This change uses the geometry function plumbing to display information there.
The original explicit title-controlling code displayed the name and arguments of the currently-executing command. This change introduces a new geometry_cmd function to display this information from within the GEOMETRY_CMDTITLE configuration.

The riskiest change in this code is the hand-rolled deansi function. The colored output of geometry functions displays poorly in the terminal title, so non-text information needed to be removed.
@duncanbeevers
Copy link
Contributor Author

@jedahan I've squashed this down to a single commit and updated the commit message with a summary and explanation of the changes.

@jedahan jedahan merged commit a8033e0 into geometry-zsh:main Sep 25, 2020
@jedahan
Copy link
Member

jedahan commented Sep 25, 2020

Thanks a bunch @duncanbeevers !

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.

2 participants