You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make it more obvious in the terminal when launching the subshell via atmos terraform shell #495
Sometimes we're in the subshell and forget that the subshell is specific to a stack and then try to plan/apply a different stack which leads to errors.
If the PS1 or something can be modified to show that atmos is in the atmos terraform shell mode, it would be very helpful.
Expected Behavior
For example, if you're in the shell stack ue1-eks, then atmos should throw a warning if you're trying to run atmos within the shell against another stack.
Use Case
Forgetting that you're in a subshell
Describe Ideal Solution
Maybe a warning or a PS1 change to show you're in a subshell
Yes, I could see that the PS1 maybe should be overridden to something plain like (atmos) ue1-eks > so it's clear you're in the shell and for which particular stack. We could then maybe disable this behavior by passing --override-ps1=false
I thought of introducing the PS1 environment variable in the componentEnvList at internal/exec/shell_utils.go#L163. I tried this on the forked setup locally but the PS1 value is not getting override :( . So for now, I don't have any alternate approach.
Bad news is, I think little can be done here, since we're just invoking a "login" (-l) shell based on SHELL. The login shell will always overwrite the environment. There's no general solution that will work, other than the developer modifying their own .zshrc or .bashrc file with a custom prompt.
Alternatively, we could make shell a parameter in the atmos.yaml, and if set, use that over the SHELL env. In that case, the default shell can be changed to not include -l, which then will not load the RC files.
Good News
The line Raj Hawaldar (@rajhawaldar) shows that it already passes the component's deep merged environment. The prompt is controlled by PS1 (for bash).
Just set the following in the Stack configuration and it should work.
env:
ATMOS_PS1: "atmos>"
# This works, but gets overridden by the shell's rc file.
# PS1: "atmos>"
Then in your local rc file, check for that variable and set the prompt to it. It's not the ideal solution, and there's nothing about calling an interactive.
If Raj Hawaldar (@rajhawaldar) wants to add the shell parameter to the atmos.yaml, and it solves the PS1, that would be appreciated.
Erik Osterman (Cloud Posse) (@osterman) Apologies for the late response. Do we really need to introduce the new shell parameter to the atmos.yaml file. The code already checks for the SHELL environment variable at line /internal/exec/shell_utils.go#L173. If user sets their desired SHELL in .zshrc or .bashrc file, then our code already picks it.
I performed following steps on my local setup, and it does the job.
I setup /usr/bin/sh as my default shell in .bashrc file export SHELL="/usr/bin/sh"
I removed the following line from the code to not run any shell as login shell.
Activity
osterman commentedon Dec 19, 2023
Yes, I could see that the PS1 maybe should be overridden to something plain like
(atmos) ue1-eks >so it's clear you're in the shell and for which particular stack. We could then maybe disable this behavior by passing--override-ps1=falserajhawaldar commentedon Dec 23, 2023
May I work on this issue Erik Osterman (Cloud Posse) (@osterman) ?
osterman commentedon Dec 23, 2023
Possibly, could you suggest your approach?
rajhawaldar commentedon Dec 24, 2023
I thought of introducing the PS1 environment variable in the componentEnvList at internal/exec/shell_utils.go#L163. I tried this on the forked setup locally but the PS1 value is not getting override :( . So for now, I don't have any alternate approach.
osterman commentedon Feb 14, 2024
Good news, bad news. Raj Hawaldar (@rajhawaldar) RB (@nitrocode)
Bad News
Bad news is, I think little can be done here, since we're just invoking a "login" (
-l) shell based onSHELL. The login shell will always overwrite the environment. There's no general solution that will work, other than the developer modifying their own.zshrcor.bashrcfile with a custom prompt.Alternatively, we could make
shella parameter in theatmos.yaml, and if set, use that over theSHELLenv. In that case, the default shell can be changed to not include-l, which then will not load the RC files.Good News
The line Raj Hawaldar (@rajhawaldar) shows that it already passes the component's deep merged environment. The prompt is controlled by
PS1(for bash).Just set the following in the Stack configuration and it should work.
Then in your local rc file, check for that variable and set the prompt to it. It's not the ideal solution, and there's nothing about calling an interactive.
If Raj Hawaldar (@rajhawaldar) wants to add the
shellparameter to theatmos.yaml, and it solves the PS1, that would be appreciated.kevcube commentedon Mar 21, 2024
Erik Osterman (Cloud Posse) (@osterman) Raj Hawaldar (@rajhawaldar) maybe something slightly higher-level, like finding some common way to edit PS1 through shell tools that many humans use, like starship.rs or oh-my-zsh etc.
rajhawaldar commentedon May 30, 2024
Erik Osterman (Cloud Posse) (@osterman) Apologies for the late response. Do we really need to introduce the new shell parameter to the
atmos.yamlfile. The code already checks for the SHELL environment variable at line /internal/exec/shell_utils.go#L173. If user sets their desired SHELL in.zshrcor.bashrcfile, then our code already picks it.I performed following steps on my local setup, and it does the job.
I setup /usr/bin/sh as my default shell in .bashrc file
export SHELL="/usr/bin/sh"I removed the following line from the code to not run any shell as login shell.
atmos/internal/exec/shell_utils.go
Line 181 in becacad
Added
componentEnvList = append(componentEnvList, "PS1=atmos>")environment variable hereatmos/internal/exec/shell_utils.go
Line 163 in becacad
Then I just got the desired prompt as below,
Erik Osterman (Cloud Posse) (@osterman), let me know your thoughts on this approach.
osterman commentedon Oct 11, 2024
I think we can do that. I think we should implement that, and add PS1 unless it explicitly set in the atmos config.
osterman commentedon Nov 8, 2024
This is addressed in #761