class: center, middle # REPL で遊ぼう --- # REPL で遊ぶとは?
この画面でいろんなものを表示させること --- # REPLでできると良いこと * Jupyter などWeb環境がなくても使える. * 単純にレトロな感じで面白い. * 思ったよりも面白い. * 今回は提供されているパッケージや小ネタをいっぱい用意した. --- # 小ネタ: バナーの表示 ```julia julia> Base.banner() _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 1.7.0 (2021-11-30) _/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release |__/ | ``` * ちなみに 🍌 はバナナ. REPL 上でも表現できる. --- # バナナの Emoji 🍌 はどう入力するの? * わからないことがあれば `? キーワードで` を入力 ```julia julia> ? # ここで ? を入力しEnterを押す. その後 🍌 を貼る: help?> 🍌 "🍌" can be typed by \:banana:
search: Couldn't find 🍌 Perhaps you meant !, %, &, ', *, +, -, /, :, <, >, \, ^, |, ~, ÷, π, ℯ, ∈, ∉, ∋, ∌ or ∘ No documentation found. Binding 🍌 does not exist. ``` * `\:banana:` と REPL で入力してから TAB キーを押す. --- # Preview Markdown * REPL 上で Markdown をプレビューできる. ```julia julia> using Markdown: parse_file julia> # あらかじめ README.md を作っておく julia> parse_file("README.md") ``` * 例: JuliaLang の README.md の一部:
--- # [In-REPL pager for Markdown](https://discourse.julialang.org/t/in-repl-pager-for-markdown/51768) * 長い文章があってスクロールをする体験をしたい場合は下記のように `less` 関数を定義する. See Julia Discourse: * [In-REPL pager for Markdown](https://discourse.julialang.org/t/in-repl-pager-for-markdown/51768) ```julia julia> using Markdown julia> function InteractiveUtils.less(md::Markdown.MD) withenv("PAGER" => "less -R -f") do file = tempname() open(io -> Markdown.term(io, md), file, "w") less(file) rm(file) end end julia> Markdown.parse_file("README.md") |> less ``` * `less` を自前で一から実装したくない人は次のスライドへ -> --- # [TerminalPager.jl](https://github.com/ronisbr/TerminalPager.jl) ```julia julia> using TerminalPager: less julia> using Markdown: parse_file julia> parse_file("README.md") |> less ``` * 矢印キー `←, ↓, ↑, →` or `h,j,k,l` で上下左右にスクロールできる. 終了する際は `q` を押す.
--- # [UnicodePlots.jl](https://github.com/JuliaPlots/UnicodePlots.jl)
--- # [UcicodeGraphics.jl](https://github.com/rafaqz/UnicodeGraphics.jl)
--- # [UnicodeFun.jl](https://github.com/SimonDanisch/UnicodeFun.jl) * $\LaTeX$ フォーマットを Julia が対応するUnicodeへ変換する. (できないものもある) ```julia julia> using UnicodeFun julia> raw"\zeta(s)" |> to_latex "ζ(s)" ``` --- # [OhMyREPL.jl](https://github.com/KristofferC/OhMyREPL.jl) * 関数のシンタックスハイライトしてくれる. 色づけは [Crayons.jl](https://github.com/KristofferC/Crayons.jl) でできる.
--- # [TerminalClock.jl](https://github.com/AtelierArith/TerminalClock.jl) * 現在時刻を表示する. 自作パッケージ
* ストップウォッチや,タイマー機能もある. * 文字盤はカスタムすることが可能. --- # [Replay.jl](https://github.com/AtelierArith/Replay.jl) * 実行手順を再生してくれる. 自作パッケージ.
🎉 --- ## ちなみに ロゴを[プルリク](https://github.com/AtelierArith/Replay.jl/pull/7)でいただくことができました. ありがとうございます!
ダークモード
--- # [Sixel.jl](https://github.com/johnnychen94/Sixel.jl) + [ImageInTerminal.jl](https://github.com/JuliaImages/ImageInTerminal.jl) * SixelGraphics 対応ターミナルでできる. * Plots.jl の描画など他の応用例は [Qiita](https://qiita.com/SatoshiTerasaki/items/3ea9750069e1d631aff7) に書いた.
--- # [VideoInTerminal.jl](https://github.com/IanButterworth/VideoInTerminal.jl) まだ野良パッケージらしいが面白い. 矢印キーで画像を遷移できる.
--- # [Animated Unicode Plots with Julia](https://mdneuzerling.com/post/animated-unicode-plots-with-julia/) * David Neuzerling さんの作品
--- # [Let it snow()](https://discourse.julialang.org/t/let-it-snow/72950) * Ian Butterworth さんの作品 Julia Discourse より * [ソースは公開されている](https://discourse.julialang.org/t/let-it-snow/72950)
--- # まとめ * Julia の REPL は思ったよりもポテンシャルがある. * REPL 芸は結構ウケが良い.