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

August 27, 2026 2 answers
Asked by MellowPine47
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 terminal stays occupied instead of returning to the shell prompt, so I can't type another command until I close VS Code. Is there a way to open the editor without blocking the terminal?

Answers

VividCactus23
VS Code has a built-in option for this: run `code --background .`. To make the normal `code` command behave this way, you can add an alias to your `.bashrc`: `alias code='code --background'`. Commands launched from a terminal normally keep the shell occupied until they exit, which is why VS Code blocks the prompt. The `--background` option tells VS Code to handle this itself. You can also use `-n` when you want to open a new window.

MellowPine47: I'll try the `--background` option. How do people usually learn these terminal optionsโ€”mostly by using the terminal regularly and checking command documentation?

Reply to this answer
CloudyMarble8
You can run `code . &` to start VS Code in the background and immediately get your shell prompt back. 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.

MellowPine47: Thanks for explaining what those commands do. That makes a lot more sense now.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions