# terminal: Clear shell after activating \(\#39798\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/439add3d237309fde31f60dbec776a57100949a8)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 439add3d237309fde31f60dbec776a57100949a8

Requested commit: 439add3d237309fde31f60dbec776a57100949a8

Commit: 439add3d237309fde31f60dbec776a57100949a8

Tree: ff6bb2160c1baad2c5977ee80d313e184347637a

Author: Jakub Konka

Committer: GitHub

## Message

```
terminal: Clear shell after activating (#39798)

Two tweaks were required to ensure we correctly clear the shell after
running an activate script(s):
1. PowerShell upon receiving `\r\n` input, will enter the continuation
mode (>>). To avoid this, we send an "enter" key press instead `\x0d`.
2. In order to clear the terminal _after_ issuing all activation
commands, we need to take into account the asynchronous nature of the
activation process:
   - We write the command to run the script to PTY
- We send "enter" (It is now being processed by the shell) At this point
we need to wait for the shell to finish executing before we clear the
terminal. Otherwise we will create a race where we might clear the
terminal _before_ the shell finished executing the activation script(s).
   - Write `clear`/`cls` command to PTY
- Send "enter" This way we guarantee that we clear the terminal _after_
all scripts were executed.

Closes #38474 

Release Notes:

- N/A
```

## Parents

- [81b98cdd4d891704239c588c44667c2c0e505cb1](https://git.cafe/gitcafe/zed/commit/81b98cdd4d891704239c588c44667c2c0e505cb1?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/439add3d237309fde31f60dbec776a57100949a8?format=markdown)
