<!DOCTYPE HTML> <html lang="" > <head> <meta charset="UTF-8"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <title>terminal ยท hello world! bluesky</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="description" content=""> <meta name="generator" content="@gitbook-ng/gitbook 3.3.6"> <meta name="author" content="syui"> <link rel="stylesheet" href="../gitbook/style.css"> <link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css"> <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css"> <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css"> <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css"> <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css"> <meta name="HandheldFriendly" content="true"/> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png"> <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon"> <link rel="next" href="3.html" /> <link rel="prev" href="1.html" /> </head> <body> <div class="book"> <div class="book-summary"> <div id="book-search-input" role="search"> <input type="text" placeholder="Type to search" /> </div> <nav role="navigation"> <ul class="summary"> <li class="chapter " data-level="1.1" data-path="../"> <a href="../"> hello world! bluesky </a> </li> <li class="chapter " data-level="1.2" data-path="../card/"> <a href="../card/"> card </a> </li> <li class="chapter " data-level="1.3" data-path="../c1/"> <a href="../c1/"> part 1 </a> <ul class="articles"> <li class="chapter " data-level="1.3.1" data-path="../c1/1.html"> <a href="../c1/1.html"> quick start </a> </li> <li class="chapter " data-level="1.3.2" data-path="../c1/2.html"> <a href="../c1/2.html"> example </a> </li> </ul> </li> <li class="chapter " data-level="1.4" data-path="./"> <a href="./"> part 2 </a> <ul class="articles"> <li class="chapter " data-level="1.4.1" data-path="1.html"> <a href="1.html"> bluesky </a> </li> <li class="chapter active" data-level="1.4.2" data-path="2.html"> <a href="2.html"> terminal </a> </li> <li class="chapter " data-level="1.4.3" data-path="3.html"> <a href="3.html"> shell </a> </li> <li class="chapter " data-level="1.4.4" data-path="4.html"> <a href="4.html"> rust </a> </li> </ul> </li> <li class="chapter " data-level="1.5" data-path="../c3/"> <a href="../c3/"> part 3 </a> <ul class="articles"> <li class="chapter " data-level="1.5.1" data-path="../c3/1.html"> <a href="../c3/1.html"> hello world </a> </li> <li class="chapter " data-level="1.5.2" data-path="../c3/2.html"> <a href="../c3/2.html"> seahorse </a> </li> <li class="chapter " data-level="1.5.3" data-path="../c3/3.html"> <a href="../c3/3.html"> reqwest </a> </li> </ul> </li> <li class="chapter " data-level="1.6" data-path="../c4/"> <a href="../c4/"> part 4 </a> <ul class="articles"> <li class="chapter " data-level="1.6.1" data-path="../c4/0.html"> <a href="../c4/0.html"> ai </a> </li> <li class="chapter " data-level="1.6.2" data-path="../c4/1.html"> <a href="../c4/1.html"> config </a> </li> <li class="chapter " data-level="1.6.3" data-path="../c4/2.html"> <a href="../c4/2.html"> mention </a> </li> <li class="chapter " data-level="1.6.4" data-path="../c4/3.html"> <a href="../c4/3.html"> base64 </a> </li> </ul> </li> <li class="chapter " data-level="1.7" data-path="../c5/"> <a href="../c5/"> part 5 </a> <ul class="articles"> <li class="chapter " data-level="1.7.1" data-path="../c5/1.html"> <a href="../c5/1.html"> notify </a> </li> <li class="chapter " data-level="1.7.2" data-path="../c5/2.html"> <a href="../c5/2.html"> timeline </a> </li> <li class="chapter " data-level="1.7.3" data-path="../c5/3.html"> <a href="../c5/3.html"> refresh </a> </li> </ul> </li> <li class="chapter " data-level="1.8" data-path="../end/"> <a href="../end/"> end </a> </li> </ul> </nav> </div> <div class="book-body"> <div class="body-inner"> <div class="book-header" role="navigation"> <!-- Title --> <h1> <i class="fa fa-circle-o-notch fa-spin"></i> <a href=".." >terminal</a> </h1> </div> <div class="page-wrapper" tabindex="-1" role="main"> <div class="page-inner"> <div id="book-search-results"> <div class="search-noresults"> <section class="normal markdown-section"> <h3 id="terminal">terminal</h3> <p>ここでは、osごとに必要なコマンドや環境を用意することを目標にします。</p> <p><code>terminal(ターミナル)</code>とはwindowsでいうcmd(コマンドプロンプト)が有名です。わかりやすく言うと黒い画面を指します。<code>端末</code>や<code>term</code>などとも呼ばれたりします。</p> <p>terminalにも色々なterminal、つまり、アプリ(ソフトウェア)があります。</p> <p>個人的には<a href="https://wezfurlong.org/wezterm/installation.html" target="_blank">wezterm</a>がオススメですが、ここでは、os固有のものを使用します。</p> <h4 id="package-manager">package manager</h4> <p>最初に、<code>package manager(パッケージ・マネージャー)</code>の解説を行います。</p> <p>今回、それぞれのosでパッケージ・マネージャーの導入が必要です。</p> <p>なお、ここでのパッケージやプログラムはアプリと言いかえることもできます。</p> <p>パッケージ・マネージャーは、アプリのインストールを簡単にしてくるものと考えてください。</p> <p>通常、アプリはsource(ソース)をbuild(ビルド)またはcompile(コンパイル)し、作成されたbinary(バイナリ)を実行することで動作します。</p> <p>windowsでいうと<code>.exe</code>がbinaryに当たります。</p> <p>binaryは、osによって異なります。</p> <p>ちなみに、sourceは<code>src</code>と略され、binaryは<code>bin</code>に略されることが多いです。</p> <p>話を戻すと、どのパッケージ(binary)をどこからダウンロードし、どこに置くのか、それらを自動処理してくれるのがパッケージマネージャーです。</p> <p>なぜこのようになっているのかというと、sourceのbuildには時間がかかるからです。</p> <p>ですから、大体のパッケージは既に当該osでbuildされているbinaryをserver(サーバー)からダウンロードしてくるだけです。</p> <p>その役割を担っているのが大半のパッケージ・マネージャーと呼ばれるものになります。</p> <p>以降、このパッケージ・マネージャーを導入して<code>terminal</code>から使うことになります。</p> <h4 id="windows">windows</h4> <p>windowsユーザーの方に向けて必要な環境を解説します。</p> <ul> <li><p>winget</p> </li> <li><p>scoop</p> </li> <li><p>windows terminal</p> </li> <li><p>wsl</p> </li> </ul> <p>windows環境は注意が必要です。windowsは基本的にdocs通り動かないということを覚えておいてください。</p> <p>例えば、<a href="https://github.com/microsoft" target="_blank">github/microsoft</a>に書いてあるコマンドを実行しても、大半は動きません。動かないことがあります。</p> <p>したがって、ご自身の環境に合わせて設定したり読み替えたりする必要が出てきます。</p> <p>まず、windowsのパッケージ・マネージャーとして<a href="https://github.com/microsoft/winget-cli" target="_blank">winget</a>を導入します。</p> <p><code>win+r</code>を押して<code>powershell</code>と入力し、<a href="https://github.com/PowerShell/PowerShell/releases/" target="_blank">powershell</a>を起動します。powershellは以降、<code>pwsh</code>と略します。</p> <p>以下のコマンドを実行します。</p> <div><p class="code-filename">pwsh</p></div> <pre><code class="lang-sh">Install-Module -Name Microsoft.W<span class="hljs-keyword">in</span>Get.Client </code></pre> <pre><code class="lang-sh">Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from <span class="hljs-string">'PSGallery'</span>? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is <span class="hljs-string">"N"</span>): A </code></pre> <p>次に<a href="https://github.com/microsoft/terminal" target="_blank">windows terminal</a>をインストールします。</p> <div><p class="code-filename">パッケージの検索</p></div> <pre><code class="lang-sh">winget search <span class="hljs-string">"windows terminal"</span> </code></pre> <pre><code> Name Id Version Source -------------------------------------------------------------------------------- Windows Terminal 9N0DX20HK701 Unknown msstore Windows Terminal Preview 9N8G5RFZ9XK3 Unknown msstore Windows Terminal Microsoft.WindowsTerminal 1.16.10261.0 winget Windows Terminal Preview Microsoft.WindowsTerminal.Preview 1.17.10234.0 winget </code></pre><div><p class="code-filename">terminalのインストール</p></div> <pre><code class="lang-sh">winget install 9N0DX20HK701 or winget install Microsoft.WindowsTerminal </code></pre> <p>windowsはshellが非常に扱いづらいので、wslでlinux(ubuntu)を動作させます。基本的にrustやshellはlinux環境を前提に解説します。</p> <div><p class="code-filename">wslの導入</p></div> <pre><code class="lang-sh">wsl --install wsl --install <span class="hljs-_">-d</span> Ubuntu </code></pre> <p>もしlinuxではなくwindows環境がいい場合は、パッケージ・マネージャーの<a href="https://scoop.sh/" target="_blank">scoop</a>などから<code>curl</code>などをインストールして対応してください。</p> <div><p class="code-filename">scoopのインストール</p></div> <pre><code class="lang-sh">Set-ExecutionPolicy RemoteSigned -Scope CurrentUser <span class="hljs-comment"># Optional: Needed to run a remote script the first time</span> irm get.scoop.sh | iex </code></pre> <div><p class="code-filename">pwsh</p></div> <pre><code class="lang-sh">scoop install curl git rust </code></pre> <p><code>pwsh</code>をinstall, updateします。</p> <pre><code class="lang-sh">winget install Microsoft.PowerShell winget upgrade --all </code></pre> <h4 id="mac">mac</h4> <ul> <li><p>terminal</p> </li> <li><p>homebrew</p> </li> </ul> <p><code>mac</code>の場合はデフォルトのterminalを使用します。</p> <p>finderを開いて<code>cmd+shift+u</code>を押します。その中にterminal(ターミナル.app)があると思います。</p> <p>まずパッケージ・マネージャーの<a href="https://brew.sh" target="_blank">homebrew</a>をインストールします。</p> <div><p class="code-filename">brewのインストール</p></div> <pre><code class="lang-sh">/bin/bash -c <span class="hljs-string">"<span class="hljs-variable">$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)</span>"</span> </code></pre> <pre><code class="lang-sh">brew install curl git zsh rust </code></pre> <p><code>cargo build</code>のerrorが出る場合、xcodeの<a href="https://developer.apple.com/forums/thread/660649" target="_blank">command line tools</a>をインストールする必要があるかもしれません。</p> <pre><code class="lang-sh">$ xcode-select --install </code></pre> <h4 id="linux">linux</h4> <p>linuxユーザーは説明が不要なので省略します。</p> <p>私は<a href="https://www.archlinux.jp/" target="_blank">archlinux</a>を使用します。</p> <pre><code class="lang-sh">pacman -Syu curl git zsh rust </code></pre> <pre><code class="lang-sh">$ cargo version cargo 1.70.0 </code></pre> </section> </div> <div class="search-results"> <div class="has-results"> <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1> <ul class="search-results-list"></ul> </div> <div class="no-results"> <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1> </div> </div> </div> </div> </div> </div> <a href="1.html" class="navigation navigation-prev " aria-label="Previous page: bluesky"> <i class="fa fa-angle-left"></i> </a> <a href="3.html" class="navigation navigation-next " aria-label="Next page: shell"> <i class="fa fa-angle-right"></i> </a> </div> <script> var gitbook = gitbook || []; gitbook.push(function() { gitbook.page.hasChanged({"page":{"title":"terminal","level":"1.4.2","depth":2,"next":{"title":"shell","level":"1.4.3","depth":2,"path":"c2/3.md","ref":"c2/3.md","articles":[]},"previous":{"title":"bluesky","level":"1.4.1","depth":2,"path":"c2/1.md","ref":"c2/1.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c2/2.md","mtime":"2023-08-14T14:12:32.025Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-09-16T08:55:27.618Z"},"basePath":"..","book":{"language":""}}); }); </script> </div> <script src="../gitbook/gitbook.js"></script> <script src="../gitbook/theme.js"></script> <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script> <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script> <script src="../gitbook/gitbook-plugin-search/search.js"></script> <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script> <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script> <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script> <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script> </body> </html>