Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ターミナルを共有するいろいろ

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

 ターミナルを共有するいろいろ

Avatar for Kenichiro MATOHARA

Kenichiro MATOHARA

October 20, 2024
Tweet

More Decks by Kenichiro MATOHARA

Other Decks in Technology

Transcript

  1. 最近 先月の textlint + Neovim スライド修正した 回線の問題で git clone がコケていたらしい……

    10月より鹿児島最低賃金 897円 → 953円に ThinkPad X260 をヤフオクで2kほどで入手 3
  2. ThinkPad X260 12.5インチ(1366x768)/Intel Core i3-6100U 2.3GHz/RAM 4GB(DDR4)/ストレ ージなし(SATA 2.5インチ)ジャンク リヤバッテリー23kWh(8割ほど),フロント内蔵バッテリーなし

    → 3時間ほど すぐフリーズする ThinkPad Yoga260 から RAM と電源(角型,扱いやすい)を,T430 か ら SSD 移植 RAM 4GB → 8GB, SSD なし → 1TB 重量1.4kgほど OS Debian bookworm → ParrotOS lory → 変えるかも? ビデオミーティングも可能な持ち運び laptop にする予定 4
  3. 5

  4. <?xml version="1.0" encoding="UTF-8" ?> <! "-//W3C//DTD XHTML 1.0 Stri "http://www.w3.org/TR/xhtml1/DTD/xhtml1-stric

    created with the aha Ansi HTML Adapter. <html xmlns="http://www.w3.org/1999/xhtml" equiv="Content-Type" content="application/xml <title>stdin</title> </head> <body> <pre weight:bold;filter: contrast(70%) brightness(190% <span style="color:yellow;"></span><span style contrast(70%) brightness(190%);color:whit style="color:red;"></span><span style="color:y style="font-weight:bold;color:#3333FF;" style="color:yellow;">)~</span> <span style="co <span style="color:red;">\</span><span style= <span style="text-decoration:und weight:bold;color:fuchsia;">oo</span><span </span> <span style="color:yellow;">/|___|,'</sp weight:bold;text-decoration:blink;filter brightness(190%);color:white;">*</span><span </span> <span style="color:lime;">wWwWwWwWwWwWwWwWwW …​ "Have you mooed today?"…​ </pre> < $ unbuffer apt moo moo | aha -b | xsel -b > apt-moo.html __ _______~(..)~ ,----\(oo) /|____|,' /\ /\ wWwWwWwWwWwWwWwWwWwWwWwWwWwWw ..."Have you mooed today?"... https:// 8
  5. termrec ttyrec のファイルを再生できる 巻き戻しや,圧縮ファイルの再生が出来るのが便利 telnet proxy も(未検証) 一時停止/再開, + 速度up,

    + 速度down, 速度等速, 1フレームず つ進める, 10秒巻き戻し, 1分巻き戻し, 10分巻き戻し, 10秒スキップ, 1分 スキップ, 10分スキップ, 最初に戻る, 終了 1KB: software/termrec $ sudo apt install termrec $ termplay ./rec.ttyrec.zst space + F - S 1 Enter ← ↓ PgDn → ↑ PgUp R Q 13
  6. asciinema 端末を保存して公開するツールやサービス asciinema rec で録画,終了時に asciinema.org にアップロードできる アップロードしたものはウェブブラウザ上で再生可能(Xterm.js 利用) blog

    などに埋め込んだりも asciinema ウェブプレイヤーはセルフホストも可能 asciinema.org にアップロードできない大きなものなどに Xterm.js は対応しているので Sixel も対応してほしい 端末操作を Web で共有出来る asciinema – matoken’s meme 16
  7. 1 認証(要ウェブブラウザ) 2 録画とアップロード 3 demo.cast というファイルに録画 4 再生 5

    asciinema.org のURL を再生 6 出力結果をcat 7 asciinema.org へ upload $ sudo apt install asciinema $ asciinema auth $ asciinema rec $ asciinema rec demo.cast $ asciinema play demo.cast $ asciinema play https://asciinema.org/a/difqlgx86ym6emrmd8u62yqu8 $ asciinema cat demo.cast $ asciinema upload demo.cast 1 2 3 4 5 6 7 17
  8. 埋め込み例 プレイヤー埋め込み _ _ _ _ _a_ _{.`=`.}_ _ _

    _{.`=`.}_ {/ ' _ {.' _ '.} {.`'`.} {.' _ '.} {| . ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{ \~~{/ .'~'. \}~~{/ .-. \}~~{/ .'~'. \}~{/ | ^^^^ ^^^ ^^^ ^^^ ^^^^ ^^^^ ^^^ ^^^ ^^^ ^^^^ ^^^^ ^^^ ^^^ ^^^^ ^^^^ ^^^ ^^ ^^^^ ^^^^ ^^^ ^^ ^^^^ ^^^^ ^^ ^^^^ ^^^ ^^^^^^ ^^ ^^^^ ^^^ ^^^^^^ ^^ ^^^^ ,--,_ __ _\.-__'-. T~~ \ '.-" <'_><o\ | /_.'-._ `\\ / /^\ `"--(/"` / \ _ _ _ / \ _ _ _ [ ]_[ ]_[ ]/ _ _ \[ ]_[ ]_[ ] |_=__-_ =_|_[ ]_[ ]_|_=-___-__| ( ( .:/ | _- = | =_ = _ |= ) | ) ) ,,///;, ,;/ |= -[] |- = _ = |_ (_[] | ( ( ( o:::::::;;/// | =_ |= - ___ | ( )= | ) ) >::::::::;;\\\ |= []- |- /| |\ |= (=[] | ( ( ( ''\\\\\'' ';\ |- =_ | =| | | | |-( )- | ) ) ) | | | | | | | ( | 画像リンク eval(T=%(eval(%(E=27.chr;Z=32.chr;$ ><<E+"[2J";K=->q{(q-q*(1-3844.0/q.abs2)**0.5) /2};I=->f,a,b,z,t=p{(a-b).abs>(f<1?1:1-(K[a]-c=K[b]). abs)?I[f,c= (a+b)/2,b,I [f,a,c,z,t],t :''''''''''''''''''''''''''''''': ]:f<1?(x,y=b. rect;d="'."[y%2 : : ];c=z[y/2+5];c[ x+=58]=t||(c[x]== : : d||Z==c[x]?d:?:)) :(puts(E+"[H"+$/+I[ : : 0,c,0,I[0,b,c,z.map (&:b)]]*$/);t||I[0,b : : ,c,z,Z];sleep(0.01)) ;z};s=(Z*25+"eval(T= : : %("+T+"))").lines.ma p{|l|l.chomp.ljust(90 : ,---. ,---. ,---. ,---. : )};loop{z=0i-31,[-1.0 ,Z];h=10i-30;a="5?GUV : | | | . | | | | : XIIPCM.AAN&,HY/ZZZO7[ &,HY3'CE<5SM5.OOJ+BBT : | | --< | | | | : 3LV+A&YQ.STT[MF.KUVXP K+&[AOOJ'&5?GU57-B5SI : | | | ' | | | | : 51>E<5PCMF.K,DXPD+SM7 .77'";i=92;"Q+3_.DW'` : `---' `---' `---' `---' : HAD,A11R`NK+HILJ/D'&F 1.CG371|BE@355?5A7@@ : : ??7|3-5-".scan(/../) {a.gsub!("%c"%i-=1,$ : : &)};Time.now.strftim e("%H:%M").bytes{|c : : |q=h;a.split(?&)[c- 48].scan(/([0-8]) : : |./){$1?q+=(n=$1. hex)%3-1+(n/3-1 : : )*2i:z<<[q,$&]} ;h+=6};z<<a=3 :...............................: 1i-31;31.time s{|y|s[y/2+ 5][58]=Z};g =z.map{|b,h|x,y=a.rect;g&&s[y/2+5][x+58]=g;I[1,a,b,s, g];a,g=b,h};sleep(61-Time.now.sec);;;}).gsub( /^(.{26}):.{32}/){$1}.split*"")##)) 18
  9. ttyrecからasciinema に変換 ttyrec で保存したデータを asciinema の asciicast形式に変換 asciinema/ttyrec2asciicast: ttyrec to

    asciicast converter $ git clone https://github.com/asciinema/ttyrec2asciicast $ python3 ./ttyrec2asciicast/ttyrec2asciicast.py input.ttyrec output.cast 19
  10. aha 端末の結果を HTML に変換 画像でのスクリーンショットより小さくなるのが便利 1 lolcat で色を付けようとしているが,後ろにパイプがあるので気を利かせて色を付けな い…… 2

    --force オプションで色を強制 3 apt コマンドでカラフルな牛が出力されるはずがパイプがあるので気を利かせて色を付け ない 4 expect 内の unbuffer で色を強制 theZiz/aha: Ansi HTML Adapter $ sudo apt install aha $ aha -h | aha --black > aha_-h.html $ cowsay hello | lolcat | aha -b > lolcat.html $ cowsay hello | lolcat --force | aha -b > lolcat.html -preview $ apt moo moo | aha -b -n $ unbuffer apt moo moo | aha -b -n 1 2 3 4 21
  11. terminal-to-html buildkite/terminal-to-html: Converts arbitrary shell output (with ANSI) into beautifully

    rendered HTML $ go install github.com/buildkite/terminal-to-html/v3/cmd/terminal-to-html@latest $ unbuffer apt moo moo | terminal-to-html -preview > apt-moo-moo2.html 22
  12. termtosvg > Note: As of June 2020 I do not

    have time to maintain termtosvg anymore and this repository is now read-only. asciinema と違い単体のファイルでウェブブラウザで再生出来るのが便利 コピペも可能 テキストエディタで編集できなくもない お手軽だが長い録画だと重くなりブラウザが反応しなくなる nbedos/termtosvg: Record terminal sessions as SVG animations $ sudo apt install termtosvg $ termtosvg Recording started, enter "exit" command or Control-D to end ^d exit Rendering ended, SVG animation is /tmp/termtosvg_s3rhpnr9.svg $ xmllint --format termtosvg_s3rhpnr9.svg 25
  13. ttygif ttyrec で録画したデータを gif に変換 大量のスクリーンショットを録っているだけなので透過背景や重なった他のウィンドウなども録 画されるので注意 icholy/ttygif: Convert terminal

    recordings to animated gifs $ sudo apt install ttygif $ ttyrec nyancat.ttyrec $ ttygif nyancat.ttyrec Creating Animated GIF ... this can take a while Created: tty.gif in the current directory! ffmpegでgifからmp4に変換した動画がInstagramに投稿できない – matoken’s meme 27
  14. 28

  15. tmate tmux からフォークして共有機能を実装したもの tmate.io を利用し,NAT を超えてWeb/SSHで端末を共有できる(セルフホストも可能) (Sixelに対応して欲しい) tmate • Instant

    terminal sharing $ sudo apt install tmate $ tmate Tip: if you wish to use tmate only for remote access, run: tmate -F [0/0] To see the following messages again, run in a tmate session: tmate show-messages Press <q> or <ctrl-c> to continue --------------------------------------------------------------------- Connecting to ssh.tmate.io... Note: clear your terminal before sharing readonly access web session read only: https://tmate.io/t/ro-VDPYzytNrDNCC4LBRYH27ZJCc ssh session read only: ssh [email protected] web session: https://tmate.io/t/n8MwFFf9DwYfA4wFz8eW54djx ssh session: ssh [email protected] 33
  16. ttyd 新しい仮想端末を起動し,ウェブ共有できる tsl0922/ttyd: Share your terminal over the web $

    sudo apt install ttyd $ ttyd -p 8080 nyancat $ xdg-open http://localhost:8080/ $ ttyd --writable -p 8080 tmux new -A -s ttyd & $ ngrok http 8080 34