add condaenv to the prompt (#355)

adding conda environment to prompt (#304)
This commit is contained in:
Mike Sawka 2024-02-28 10:00:06 -08:00 committed by GitHub
parent 0464cccf0a
commit bbf471566f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -115,6 +115,7 @@ class Prompt extends React.Component<{ rptr: RemotePtrType; festate: Record<stri
}
let branchElem = null;
let pythonElem = null;
let condaElem = null;
if (!isBlank(festate["PROMPTVAR_GITBRANCH"])) {
let branchName = festate["PROMPTVAR_GITBRANCH"];
branchElem = (
@ -132,9 +133,17 @@ class Prompt extends React.Component<{ rptr: RemotePtrType; festate: Record<stri
</span>
);
}
if (!isBlank(festate["CONDA_DEFAULT_ENV"])) {
let condaEnv = festate["CONDA_DEFAULT_ENV"];
condaElem = (
<span title="conda env" className="term-prompt-python">
conda:({condaEnv}){" "}
</span>
);
}
return (
<span className={cn("term-prompt", { "term-prompt-color": this.props.color })}>
{remoteElem} {pythonElem}
{remoteElem} {condaElem} {pythonElem}
{cwdElem} {branchElem} {rootIndicatorElem}
</span>
);

View File

@ -749,6 +749,9 @@ func FeStateFromShellState(state *packet.ShellState) map[string]string {
if envMap["VIRTUAL_ENV"] != "" {
rtn["VIRTUAL_ENV"] = envMap["VIRTUAL_ENV"]
}
if envMap["CONDA_DEFAULT_ENV"] != "" {
rtn["CONDA_DEFAULT_ENV"] = envMap["CONDA_DEFAULT_ENV"]
}
for key, val := range envMap {
if strings.HasPrefix(key, "PROMPTVAR_") && envMap[key] != "" {
rtn[key] = val