# How to programmatically open Pluto in a VS Code new tab from the Julia Terminal?

**URL:** <https://discourse.julialang.org/t/how-to-programmatically-open-pluto-in-a-vs-code-new-tab-from-the-julia-terminal/126086>\
**Category:** General Usage\
**Tags:** pluto\
**Created:** [February 19, 2025, 6:27pm UTC](https://discourse.julialang.org/t/how-to-programmatically-open-pluto-in-a-vs-code-new-tab-from-the-julia-terminal/126086 "2025-02-19T18:27:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![askvorts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/askvorts/32/7120_2.png) [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Post date:** [February 19, 2025, 6:27pm UTC](https://discourse.julialang.org/t/how-to-programmatically-open-pluto-in-a-vs-code-new-tab-from-the-julia-terminal/126086/1 "2025-02-19T18:27:18Z")

</div>

I am trying to capture the Pluto URL programmatically ’ `pluto_url = some code`’ without auto-open and afterwards opening it inside VS Code. Is it possible?

```julia
using Pluto
# Start Pluto 
@async Pluto.run(; autoopen=false) 

# Capture the Pluto URL ensuring the secret token is included
pluto_url = some code

# Pluto uses VS Code’s internal browser in a new tab
@async run(`code --reuse-window "$pluto_url"`)

```

---

<div class="post-metadata">

**Author:** ![g-gundam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/g-gundam/32/47593_2.png) [@g-gundam](https://discourse.julialang.org/u/g-gundam)\
**Post date:** [February 20, 2025, 4:26pm UTC](https://discourse.julialang.org/t/how-to-programmatically-open-pluto-in-a-vs-code-new-tab-from-the-julia-terminal/126086/2 "2025-02-20T16:26:09Z")

</div>

## Run Pluto the Long Way

```julia-repl
julia> using Pluto

julia> options = Pluto.Configuration.from_flat_kwargs(; launch_browser=false);

julia> session = Pluto.ServerSession(; options, secret="password");

julia> pluto_url = Pluto.pretty_address(session, options.server.host, options.server.port_hint)
"http://localhost:1234/?secret=password"

julia> t = @async Pluto.run(session);

julia> @async run(`code --reuse-window "$pluto_url"`)

```

Set the password to whatever you want.

---

<div class="post-metadata">

**Author:** ![askvorts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/askvorts/32/7120_2.png) [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Post date:** [February 20, 2025, 8:56pm UTC](https://discourse.julialang.org/t/how-to-programmatically-open-pluto-in-a-vs-code-new-tab-from-the-julia-terminal/126086/3 "2025-02-20T20:56:28Z")

</div>

Thank you very much for your help. When I run your script (on a Mac) it opens VS Code with a tab named ?secret=password but no Pluto running.

 ![vscode](https://global.discourse-cdn.com/julialang/original/3X/0/d/0d8f1b78ca03572fc873fda99e89ab6273268a5b.png)  
I wonder if possibly the `t` in `t = @async Pluto.run(session);` should be used somewhere afterwards?

---

<div class="post-metadata">

**Author:** ![g-gundam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/g-gundam/32/47593_2.png) [@g-gundam](https://discourse.julialang.org/u/g-gundam)\
**Post date:** [February 20, 2025, 11:05pm UTC](https://discourse.julialang.org/t/how-to-programmatically-open-pluto-in-a-vs-code-new-tab-from-the-julia-terminal/126086/4 "2025-02-20T23:05:13Z")

</div>

#### Regarding the `?secret=password` tab

I don’t know how to open a web page in VS Code from the command line. I don’t normally use VS Code, so I was trusting your `run` expression worked. I looked into it a bit, but I couldn’t find anything. What does:

```bash
code https://www.google.com/

```

do for you? I get an empty tab and not the SimpleBrowser tab I was hoping for.

#### Regarding `t = @async Pluto.run(session)`

If you’re running this as a script outside of the REPL, put a `wait(t)` at the end. Otherwise, the script will exit and the Pluto server will stop.

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [February 21, 2025, 1:01pm UTC](https://discourse.julialang.org/t/how-to-programmatically-open-pluto-in-a-vs-code-new-tab-from-the-julia-terminal/126086/5 "2025-02-21T13:01:58Z")

</div>

While VSCode can open urls using the integrated `SimpleBrowser` extension, it does not seem like there is an easy/official way of executing commands provided by VSCode extension directly using the VSCode cli from the command line.  
See for example these links from stackoverflow: [[1]](https://stackoverflow.com/questions/54409369/possible-to-invoke-a-vscode-extension-command-from-command-line), [[2]](https://stackoverflow.com/questions/68460556/can-a-command-be-send-to-vscode-directly-from-the-integrated-terminal-integrat)
