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

Display session name within zellij #608

Merged
merged 6 commits into from
Jul 22, 2021

Conversation

CosmicHorrorDev
Copy link
Contributor

Closes #573

This displays the session name next to Zellij in the top-left corner by passing the information in ModeInfo as described in #573. Example:

image

The session name is stored as an Option<String> so if, for whatever reason, None gets passed to the plugins then the name will fall back to the old style of just displaying Zellij. I did this because the State for the plugin has to implement Default, but I haven't been able to see a situation where it receives None.

This currently gets the session name by reading the ZELLIJ_SESSION_NAME env var, but I would prefer to have the name passed in as a String instead and am planning on making this change before switching this off a draft.

I did also move get_mode_info() into zellij_tile as ModeInfo::new() since it seemed like the function was just serving as a constructor for ModeInfo, but let me know if there was any compelling reason to keep it as a separate function in a different crate.

Also just to note from a new contributor I had to:

  • Remove -C target-cpu=native from my rustflags to get the wasm portions to build without erroring
  • Install the Linux musl target from rustup along with the musl C standard library from my package manager
    • rustup target add x86_64-unknown-linux-musl
    • sudo pacman -S musl for Arch at least

@a-kenji
Copy link
Contributor

a-kenji commented Jul 9, 2021

Thank you for this pr!

I did also move get_mode_info() into zellij_tile as ModeInfo::new() since it seemed like the function was just serving as a constructor for ModeInfo, but let me know if there was any compelling reason to keep it as a separate function in a different crate.

I like it much more after your change. I think we thought already about moving it.
Maybe someone else has more input on that. cc @TheLostLambda

Also just to note from a new contributor I had to:

* Remove `-C target-cpu=native` from my `rustflags` to get the wasm portions to build without erroring

How did you set up your toolchain? Does the rust-toolchain file inherit
global rustflags? Maybe we need to investigate more what happened here.

* Install the Linux musl target from `rustup` along with the musl C standard library from my package manager
  
  * `rustup target add x86_64-unknown-linux-musl`
  * `sudo pacman -S musl` for Arch at least

The musl target is only used for the e2e tests right now,
maybe we need to look a little bit more on splitting the dependencies up.

And a little bit general feedback:

For me personally the string is a bit long.
I would like to see the session name without the zellij prefix.
But maybe that is too confusing for especially new users,
maybe it would make sense to just show the session name by default
when it is set manually rather than generated?

This is all still a little bit complicated since we haven't fleshed out
a system for configuring the plugins yet.

@TheLostLambda
Copy link
Member

This is looking quite cool in general! Just a note about this bit:

I did also move get_mode_info() into zellij_tile as ModeInfo::new() since it seemed like the function was just serving as a constructor for ModeInfo, but let me know if there was any compelling reason to keep it as a separate function in a different crate

The compelling reason here is that everything in zellij_tile gets compiled into every plugin. In my opinion, there is really no case in which ModeInfo::new() would be needed by a plugin. It seems (to me) to be exclusively used by Zellij itself. Even if a plugin did have a reason to call this constructor, it's likely that it would fail to capture the correct session-name because plugins can have different environment variables from the main Zellij process.

I'd personally go back to the get_mode_info() approach so that it's impossible for a plugin developer to get confused and attempt to call this function. Let me know what you think though!

@CosmicHorrorDev
Copy link
Contributor Author

CosmicHorrorDev commented Jul 9, 2021

@a-kenji

How did you set up your toolchain? Does the rust-toolchain file inherit
global rustflags? Maybe we need to investigate more what happened here.

Checking over things again, it came from setting lld as my linker in my cargo config

[build]
rustflags = "-C link-arg=-fuse-ld=lld

Building the plugins just had a lot of text about ignoring settings caused by having target-cpu=native set which is what threw me off, but the builderror was actually from trying to use lld as my linker

For me personally the string is a bit long.
I would like to see the session name without the zellij prefix.
But maybe that is too confusing for especially new users,
maybe it would make sense to just show the session name by default
when it is set manually rather than generated?

I went ahead and changed it to just display the session name (falling back to Zellij if it's somehow not set). It would take a bit more work to only display it when the session name isn't generated since it requires somehow passing and possibly storing that information.


@TheLostLambda

The compelling reason here is that everything in zellij_tile gets compiled into every plugin. In my opinion, there is really no case in which ModeInfo::new() would be needed by a plugin. It seems (to me) to be exclusively used by Zellij itself. Even if a plugin did have a reason to call this constructor, it's likely that it would fail to capture the correct session-name because plugins can have different environment variables from the main Zellij process.

I think that's a very good reasoning. I went ahead and moved it back into zellij-utils/input/mod.rs as get_mode_info()

@a-kenji
Copy link
Contributor

a-kenji commented Jul 13, 2021

@TheLostLambda thank you for the insight - that makes a lot of sense.

I went ahead and changed it to just display the session name (falling back to Zellij if it's somehow not set). It would take a bit more work to only display it when the session name isn't generated since it requires somehow passing and possibly storing that information.

Thank you for changing that, but I think if it is not configurable yet, then the
prior state that you already had was a better default.

Copy link
Contributor

@a-kenji a-kenji left a comment

Choose a reason for hiding this comment

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

Thank you for this awesome pr! With this little change I think it is ready to be merged.

default-plugins/tab-bar/src/line.rs Show resolved Hide resolved
@CosmicHorrorDev CosmicHorrorDev marked this pull request as ready for review July 20, 2021 17:30
@CosmicHorrorDev
Copy link
Contributor Author

Sorry life got busy (moving and all), so I left this PR out to dry on accident. I went ahead and reverted the commit so it's back to displaying Zellij (<session-name>) now. Let me know if there are any other changes that you all want.

I think I'll leave the current method for getting the session name as well instead of trying to weave that information through everything (although if you all want that changed then feel free to do so! I'm sure it would be much easier for people that are more familiar with the codebase)

Copy link
Contributor

@a-kenji a-kenji left a comment

Choose a reason for hiding this comment

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

No problem, life has priority! I wasn't sure if I was clear enough that's why I tried to explain it in a different way.
Thank you for this awesome work.
I think this looks good for now.

Copy link
Contributor

@a-kenji a-kenji left a comment

Choose a reason for hiding this comment

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

Thank you very much! I went ahead and merged it now.

@a-kenji a-kenji merged commit 69173ac into zellij-org:main Jul 22, 2021
@techhazard
Copy link

@LovecraftianHorror Thank you so much!

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.

[Request] Display session name in Zellij
4 participants