# How to launch interactive GLMakie script from terminal

**URL:** <https://discourse.julialang.org/t/how-to-launch-interactive-glmakie-script-from-terminal/124695>\
**Category:** New to Julia\
**Created:** [January 12, 2025, 1:37pm UTC](https://discourse.julialang.org/t/how-to-launch-interactive-glmakie-script-from-terminal/124695 "2025-01-12T13:37:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [January 12, 2025, 1:37pm UTC](https://discourse.julialang.org/t/how-to-launch-interactive-glmakie-script-from-terminal/124695/1 "2025-01-12T13:37:41Z")

</div>

I have a script for an interactive plot made with GLMakie. The script works on REPL (launched via VS Code).  
However, I would like to launch the script from terminal directly. Thus, I wrote a script in bash to launch the julia file. The file is launched, but the GLMakie is not displayed and then the julia script crashes.  
In this example, this is the julia file (`testButton.jl`):

```julia
using GLMakie
println("Starting Julia script")
xs = range(0, 10, length = 30)
ys = 0.5 .* sin.(xs)
fig = Figure()
ax = Axis(fig[1,1], title = "Example", ylabel = "Y", xlabel = "X")
sc = scatter
lines!(ax, xs, ys, linewidth = 5, color =:midnightblue)
fig[2,1] = buttongrid = GridLayout(tellwidth = false)
buttons = buttongrid[1,1] = [
    Button(fig, label = "Save Figure", fontsize = 18)
]
on(buttons[1].clicks) do click
    save("Test.png", fig)
end

```

and this is the launcher (`ButtonLauncher`):

```julia
#!/usr/bin/env bash

printf "Launching test button\n"
exec julia testButton.jl
printf "Task completed\n"
exit 0

```

When I launch the application, I get:

```julia
$ ./ButtonLauncher 
Launching test button
Starting Julia script
$ 

```

This means the script is launched (first `printf` statement) but the application does not reach the end (second `printf` statement). To note that I launched the Julia file with `exec` to remain within the bash environment.  
How can I launch an interactive plot from terminal?  
Thank you

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 12, 2025, 2:19pm UTC](https://discourse.julialang.org/t/how-to-launch-interactive-glmakie-script-from-terminal/124695/2 "2025-01-12T14:19:59Z")

</div>

> [@Luigi\_Marongiu](#):
>
> This means the script is launched (first `printf` statement) but the application does not reach the end (second `printf` statement). To note that I launched the Julia file with `exec` to remain within the bash environment.

Note that `exec` does not start a new process for Julia alongside the shell process, it _replaces_ the shell process. This means that it should be expected that whatever remains in the shell script will never be executed.

  

> [@Luigi\_Marongiu](#):
>
> How can I launch an interactive plot from terminal?

I think what happens here is that your Julia script correctly starts but immediately stops because it does not have anything to wait for. As a first step to test this hypothesis, I think one thing you can try using the `-i` command-line switch: this switches Julia to “interactive” mode. With this a Julia REPL will open and so should your GLMakie window. When you close the Julia REPL (e.g. with ctrl+d) the GLMakie window should be killed too.

You launcher script would then look like:

```sh
#!/usr/bin/env bash

printf "Launching test button\n"
julia -i testButton.jl
printf "Task completed\n"
exit 0

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 12, 2025, 2:32pm UTC](https://discourse.julialang.org/t/how-to-launch-interactive-glmakie-script-from-terminal/124695/3 "2025-01-12T14:32:02Z")

</div>

You can also try the suggestion here to call `wait`

> [@Makie doesn't show anything when run as a script](https://discourse.julialang.org/t/makie-doesnt-show-anything-when-run-as-a-script/97664/7):
>
> On the phone so haven’t tried, but I believe you can also call wait on the return from display to wait until the window decides it is done. E.g. wait(display(fig))

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [January 23, 2025, 6:52am UTC](https://discourse.julialang.org/t/how-to-launch-interactive-glmakie-script-from-terminal/124695/4 "2025-01-23T06:52:15Z")

</div>

I tried with `julia -i testButton.jl`; I get the Julia prompt on the terminal, but nothing else happens. I think the script stops at `julia -i` but does not launch the jl file itself…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 23, 2025, 10:26am UTC](https://discourse.julialang.org/t/how-to-launch-interactive-glmakie-script-from-terminal/124695/5 "2025-01-23T10:26:07Z")

</div>

You have to call `display(fig)` or no window will open. That doesn’t happen just because you create a `Figure`

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [January 23, 2025, 2:11pm UTC](https://discourse.julialang.org/t/how-to-launch-interactive-glmakie-script-from-terminal/124695/6 "2025-01-23T14:11:19Z")

</div>

Thanks, that’s it.
