-
Notifications
You must be signed in to change notification settings - Fork 806
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
feat: set the program environment variables #1063
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing!
Two questions with this one:
I'd also add a very short example to this PR (and probably the doc comments) so we can reference it later. |
This gives the option to provide a custom set of environment variables to use in the Bubble Tea program. When running Bubble Tea in a remote session such as SSH, we need to be able to pass the SSH session's environment variables rather than the server ones.
Added an example in the code comment
No, bubbletea programs default to
The bubbletea middleware should pass the SSH session's environment to the program. The middleware should include something like: var sess ssh.Session // ssh.Session is a type from the github.com/charmbracelet/ssh package
pty, _, _ := sess.Pty()
environ := append(sess.Environ(), "TERM="+pty.Term)
p := tea.NewProgram(model, tea.WithEnvironment(environ) |
By default, the TERM environment variable is sent separately in the `pry-req` request when the session is a PTY session. Other environment variables have their own request type `env` and get handled separately. This combines these two and returns a slice that contains TERM and all other sent environment variables. Refs: charmbracelet/bubbletea#1063
By default, the TERM environment variable is sent separately in the `pry-req` request when the session is a PTY session. Other environment variables have their own request type `env` and get handled separately. This combines these two and returns a slice that contains TERM and all other sent environment variables. Refs: charmbracelet/bubbletea#1063
This adds the option to provide a custom set of environment variables to use in the Bubble Tea program. When running Bubble Tea in a remote session such as SSH, we need to be able to pass the SSH session's environment variables rather than the server ones.
Now, the Bubble Tea program running for a remote session can determine the appropriate color profile from the session's environment variables instead of the server's environment variables.
In most cases you'll only need this feature when using Bubble Tea in remote sessions.