How can I keep using the WSL terminal after running `code .`?

August 27, 2026 2 answers
Asked by MellowCedar47
I'm following The Odin Project to learn web development and use Ubuntu through WSL. When I run `code .` to open Visual Studio Code, the command keeps control of the terminal, so I don't get the shell prompt back until I close VS Code. Is there a way to launch it without blocking the terminal?

Answers

PixelHarbor8
Run `code . &` to start VS Code in the background and immediately return to the shell prompt. If you also want it to keep running after the terminal closes, use `code . & disown`. The `&` backgrounds the process, while `disown` removes it from the shell's job list.

CobaltWren52: That makes senseโ€”the ampersand lets the shell and VS Code run separately, while `disown` prevents the terminal from taking responsibility for the editor after it closes.

Reply to this answer
QuietMaple31
VS Code has its own option for this: `code --background`. You can make that the default by adding `alias code='code --background'` to your `.bashrc`. You can also use `code -n` when you want the command to open a new window. In general, commands keep the terminal occupied while they're running, so long-running programs either need a background operator like `&` or a command-line option that handles background execution.

MellowCedar47: Thanks! I'll try the alias. How do people usually learn these terminal optionsโ€”mostly by using the terminal regularly and checking command documentation when something behaves unexpectedly?

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions