diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index 5ebbfb03f3f330..0ba1edb55385c2 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -1006,6 +1006,11 @@ func buildChildProcEnv(cfg *Config, envvars []string, runGP bool) []string { envs["JAVA_TOOL_OPTIONS"] += fmt.Sprintf(" -Xmx%sm", mem) } + if _, ok := envs["HISTFILE"]; !ok { + envs["HISTFILE"] = "/workspace/.gitpod/.shell_history" + envs["PROMPT_COMMAND"] = "history -a" + } + var env, envn []string for nme, val := range envs { log.WithField("envvar", nme).Debug("passing environment variable to IDE") diff --git a/components/supervisor/pkg/supervisor/supervisor_test.go b/components/supervisor/pkg/supervisor/supervisor_test.go index 911ee832b70f59..961e7a11433f66 100644 --- a/components/supervisor/pkg/supervisor/supervisor_test.go +++ b/components/supervisor/pkg/supervisor/supervisor_test.go @@ -21,6 +21,8 @@ func TestBuildChildProcEnv(t *testing.T) { "SUPERVISOR_ADDR=localhost:8080", "HOME=/home/gitpod", "USER=gitpod", + "HISTFILE=/workspace/.gitpod/.shell_history", + "PROMPT_COMMAND=history -a", ) } @@ -85,16 +87,18 @@ func TestBuildChildProcEnv(t *testing.T) { }, }, { - Name: "ots", - Input: []string{}, - OTS: `[{"name":"foo","value":"bar"},{"name":"GITPOD_TOKENS","value":"foobar"}]`, - Expectation: []string{"HOME=/home/gitpod", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod", "foo=bar"}, + Name: "ots", + Input: []string{}, + OTS: `[{"name":"foo","value":"bar"},{"name":"GITPOD_TOKENS","value":"foobar"}]`, + Expectation: []string{"HOME=/home/gitpod", "HISTFILE=/workspace/.gitpod/.shell_history", + "PROMPT_COMMAND=history -a", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod", "foo=bar"}, }, { - Name: "failed ots", - Input: []string{}, - OTS: `invalid json`, - Expectation: []string{"HOME=/home/gitpod", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod"}, + Name: "failed ots", + Input: []string{}, + OTS: `invalid json`, + Expectation: []string{"HOME=/home/gitpod", "HISTFILE=/workspace/.gitpod/.shell_history", + "PROMPT_COMMAND=history -a", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod"}, }, }