関連記事
GitHub - devlights/blog-summary: ブログ「いろいろ備忘録日記」のまとめ
概要
以下、自分用のメモです。忘れないうちにメモメモ。。
Githubさんのおすすめで出てきて初めて知ったのですが、Nushellというシェルがあるのですね。
全然知らなかったです。Powershellのようにパイプラインをテキストが流れるのではなくて、「データ」が流れる感じ。Rustで作られているんですね。
面白そうなので、ちょっと興味が湧きました。しばらく使ってみよう。
とりあえず、インストール。
インストール
Windows、Linuxのどちらもインストールはめっちゃ簡単。
Linuxの場合は brew で一発です。
$ brew install nushell
Windowsの場合も scoop で一発でした。
$ scoop install nu
scoopの場合は nushell ではなくて nu
なのに注意。
起動
シェル上で nu
で起動します。
__ , .--()°'.' Welcome to Nushell, '|, . ,' based on the nu language, !_-(_\ where all data is structured! Please join our Discord community at https://discord.gg/NtAbbGn Our GitHub repository is at https://github.com/nushell/nushell Our Documentation is located at https://nushell.sh Tweet us at @nu_shell Learn how to remove this at: https://nushell.sh/book/configuration.html#remove-welcome-message It's been this long since Nushell's first commit: 4yrs 7months 30days 12hrs 8mins 21secs 29ms 327µs 200ns Startup Time: 602ms 575µs 200ns ~>
起動が速いですねー。pwshさん起動遅いので、俄然乗り換える気持ちが強くなりました。
ちょこっとだけお試し
とりあえず、helpって打ったら大抵なんかヘルプでてくると思ったので、打ってみる。
~> help 14:09:58Welcome to Nushell. Here are some tips to help you get started. * help -h or help help - show available `help` subcommands and examples * help commands - list all available commands * help <name> - display help about a particular command, alias, or module * help --find <text to search> - search through all help commands table Nushell works on the idea of a "pipeline". Pipelines are commands connected with the '|' character. Each stage in the pipeline works together to load, parse, and display information to you. [Examples] List the files in the current directory, sorted by size: ls | sort-by size Get information about the current system: sys | get host Get the processes on your system actively using CPU: ps | where cpu > 0 You can also learn more at https://www.nushell.sh/book/
* help commands - list all available commands
って書いてあるので、利用可能コマンド一覧を見てみます。
~> help commands 14:11:03 ╭─────┬──────────────────────────┬────────────────────────┬──────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────╮ │ # │ name │ category │ command_type │ usage │ ... │ ├─────┼──────────────────────────┼────────────────────────┼──────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────┤ │ 0 │ alias │ core │ keyword │ Alias a command (with optional flags) to a new name. │ ... │ │ 1 │ all │ filters │ builtin │ Test if every element of the input fulfills a predicate expression. │ ... │ │ 2 │ ansi │ platform │ builtin │ Output ANSI codes to change color and style of text. │ ... │ │ 3 │ ansi gradient │ platform │ builtin │ Add a color gradient (using ANSI color codes) to the given string. │ ... │ │ 4 │ ansi link │ platform │ builtin │ Add a link (using OSC 8 escape sequence) to the given string. │ ... │ │ 5 │ ansi strip │ platform │ builtin │ Strip ANSI escape sequences from a string. │ ... │ │ 6 │ any │ filters │ builtin │ Tests if any element of the input fulfills a predicate expression. │ ... │ │ 7 │ append │ filters │ builtin │ Append any number of rows to a table. │ ... │ │ 8 │ ast │ debug │ builtin │ Print the abstract syntax tree (ast) for a pipeline. │ ... │ │ 9 │ banner │ default │ custom │ print a banner for nushell, with information about the project │ ... │ 割愛 ・ ・ │ 534 │ with-env │ env │ builtin │ Runs a block with an environment variable set. │ ... │ │ 535 │ wrap │ filters │ builtin │ Wrap the value into a column. │ ... │ │ 536 │ zip │ filters │ builtin │ Combine a stream with the input. │ ... │ ├─────┼──────────────────────────┼────────────────────────┼──────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────┤ │ # │ name │ category │ command_type │ usage │ ... │ ╰─────┴──────────────────────────┴────────────────────────┴──────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────╯
山程出てきた!めっちゃありますね。きれいに罫線つけて表示してくれるんですねー素晴らしい。
一気に出てくるとしんどいので、ページャを挟みたいなって思いました。
さっきのヘルプの表示に
* help --find <text to search> - search through all help commands table
ってあったので、これで聞いてみます。
~> help --find pager 14:12:58 ╭───┬─────────┬──────────┬──────────────┬────────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────┬─────╮ │ # │ name │ category │ command_type │ usage │ params │ ... │ ├───┼─────────┼──────────┼──────────────┼────────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────┼─────┤ │ 0 │ explore │ viewers │ builtin │ Explore acts as a table pager, just like `less` does for text. │ ╭───┬───────────────┬────────┬──────────┬────────────────────────────────────────────────────╮ │ ... │ │ │ │ │ │ │ │ # │ name │ type │ required │ description │ │ │ │ │ │ │ │ │ ├───┼───────────────┼────────┼──────────┼────────────────────────────────────────────────────┤ │ │ │ │ │ │ │ │ │ 0 │ --help(-h) │ switch │ false │ Display the help message for this command │ │ │ │ │ │ │ │ │ │ 1 │ --head │ bool │ false │ Show or hide column headers (default true) │ │ │ │ │ │ │ │ │ │ 2 │ --index(-i) │ switch │ false │ Show row indexes when viewing a list │ │ │ │ │ │ │ │ │ │ 3 │ --reverse(-r) │ switch │ false │ Start with the viewport scrolled to the bottom │ │ │ │ │ │ │ │ │ │ 4 │ --peek(-p) │ switch │ false │ When quitting, output the value of the cell the │ │ │ │ │ │ │ │ │ │ │ │ │ │ cursor was on │ │ │ │ │ │ │ │ │ ╰───┴───────────────┴────────┴──────────┴────────────────────────────────────────────────────╯ │ │ ╰───┴─────────┴──────────┴──────────────┴────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────┴─────╯
おけおけ、explore
ってコマンドを使うのね。
Explore acts as a table pager, just like
less
does for text. (exploreは、less
がテキストに対して行うのと同じように、テーブル・ページャーとして機能するよ)
ってことで、さっきの出力をexploreにパイプで送ってあげてみる。
~> help commands | explore
おけー。
Nushell Book
ヘルプ出力の一番下を見ると
You can also learn more at https://www.nushell.sh/book/
って書いてありますね。URLにbookってなってるので、本があるのかな。
めっちゃしっかりしたドキュメントがあるじゃないですか。素晴らしい。
これをやれば、覚えられそう。
触ってて面白いので、しばらく遊んでみようと思います。
参考情報
過去の記事については、以下のページからご参照下さい。
サンプルコードは、以下の場所で公開しています。