# Capture a Julia output in the clipboard

**URL:** https://discourse.julialang.org/t/capture-a-julia-output-in-the-clipboard/91186
**Category:** General Usage
**Created:** [December 3, 2022, 6:37pm UTC](https://discourse.julialang.org/t/capture-a-julia-output-in-the-clipboard/91186 "2022-12-03T18:37:11Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)
#### Post date: [December 3, 2022, 8:18pm UTC](https://discourse.julialang.org/t/capture-a-julia-output-in-the-clipboard/91186/8 "2022-12-03T20:18:51Z")

</div>

There may be an easier way but this seems to work:

```julia
julia> function myclipboard(x)
           iob = IOBuffer()
           show(iob, MIME"text/plain"(), x)
           str = String(take!(iob))
           clipboard(str)
       end
myclipboard (generic function with 1 method)

julia> x = [rand(3) for _ in 1:10]
10-element Vector{Vector{Float64}}:
 [0.0006688071063627454, 0.32438290031630856, 0.8963609977463138]
 [0.07447459439615989, 0.10858832326591139, 0.21761763049060934]
 [0.9474289304279342, 0.17597397164449635, 0.4534076639611243]
 [0.4745593192888291, 0.6805225170543437, 0.8428815292562719]
 [0.8008939242075624, 0.8933863723806169, 0.25332293783855564]
 [0.9801185523169914, 0.9014589729035086, 0.2976324614235306]
 [0.075404589462707, 0.17769135609527553, 0.54928725746172]
 [0.27625669533731967, 0.7821048947678795, 0.1840168069047895]
 [0.7481177179768426, 0.13077867820640932, 0.7906552800286413]
 [0.4480463507156114, 0.5866234993545199, 0.7985719519088222]

julia> myclipboard(x)

julia> clipboard()
"10-element Vector{Vector{Float64}}:\n [0.0006688071063627454, 0.32438290031630856, 0.8963609977463138]\n [0.07447459439615989, 0.10858832326591139, 0.21761763049060934]\n [0.9474289304279342, 0.17597397164449635, 0.4534076639611243]\n [0.4745593192888291, 0.6805225170543437, 0.8428815292562719]\n [0.8008939242075624, 0.8933863723806169, 0.25332293783855564]\n [0.9801185523169914, 0.9014589729035086, 0.2976324614235306]\n [0.075404589462707, 0.17769135609527553, 0.54928725746172]\n [0.27625669533731967, 0.7821048947678795, 0.1840168069047895]\n [0.7481177179768426, 0.13077867820640932, 0.7906552800286413]\n [0.4480463507156114, 0.5866234993545199, 0.7985719519088222]"

julia> println(clipboard())
10-element Vector{Vector{Float64}}:
 [0.0006688071063627454, 0.32438290031630856, 0.8963609977463138]
 [0.07447459439615989, 0.10858832326591139, 0.21761763049060934]
 [0.9474289304279342, 0.17597397164449635, 0.4534076639611243]
 [0.4745593192888291, 0.6805225170543437, 0.8428815292562719]
 [0.8008939242075624, 0.8933863723806169, 0.25332293783855564]
 [0.9801185523169914, 0.9014589729035086, 0.2976324614235306]
 [0.075404589462707, 0.17769135609527553, 0.54928725746172]
 [0.27625669533731967, 0.7821048947678795, 0.1840168069047895]
 [0.7481177179768426, 0.13077867820640932, 0.7906552800286413]
 [0.4480463507156114, 0.5866234993545199, 0.7985719519088222]

```

---

_[View the full topic](https://discourse.julialang.org/t/capture-a-julia-output-in-the-clipboard/91186)._
