Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ja/book/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
* [テーブル](working_with_tables.md) - テーブルを利用してみよう
* [パイプライン](pipeline.md) - パイプラインの仕組み
* [設定](configuration.md) - nushellの設定方法
* [エイリアス](aliases.md) - コードブロックに名前をつけよう
* [Math](math.md) - nushellで計算する
* [環境変数](environment.md) - 環境変数の設定
* [メタデータ](metadata.md) - nushellにおけるメタデータについて
* [シェル](shells_in_shells.md) - 複数の場所で作業しよう
* [コマンドのエスケープ](escaping.md) - Nuコマンドと同じ名前のコマンドを実行するには
* [プラグイン](plugins.md) - プラグインを利用してnushellを拡張する
* [プラグイン](plugins.md) - プラグインを利用してnushellを拡張する
* [Bashから来た人向け](coming_from_bash.md) - bashからnushellに来た人向けガイド
* [shells/DSLとnushellの対応表](nushell_map.md) - nushellとSQL, Linq, PowerShell, Bashとの対応表。コントリビューション歓迎。
* [命令形言語とnushellの対応表](nushell_map_imperative.md) - nushellとPython, Kotlin, C++, C#, Rustとの対応表。コントリビューション歓迎。
* [関数型言語とnushellの対応表](nushell_map_functional.md) - nushellとClojure, Tablecloth (Ocaml / Elm), Haskellとの対応表。コントリビューション歓迎。
* [Nushell演算子対応表](nushell_operator_map.md) - 演算子の対応表。

50 changes: 50 additions & 0 deletions ja/book/aliases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# エイリアス

Nuではパイプラインを利用して自由にデータやシステムを操作できますが、その反面多くのタイピングを要してしまいます。一度作成したパイプラインを保存しておき再利用できるようにしておきたいところです。

そこでエイリアスの出番です。

エイリアスを使うとコマンドのブロックに名前をつけることができます。エイリアスを実行するとそのコマンドブロックが実行されます。

例:

```
> alias ls-names [] { ls | select name }
> ls-names
────┬────────────────────
# │ name
────┼────────────────────
0 │ 404.html
1 │ CONTRIBUTING.md
2 │ Gemfile
3 │ Gemfile.lock
4 │ LICENSE
```

## パラメータ

エイリアスは、ブロックに渡されるオプションのパラメータをもつことができます。これらはブロック内の新しい変数になります。

```
> alias e [msg] { echo $msg }
> e "hello world"
hello world
```

パラメータは任意の数設定することができ、ユーザが値を提供しなかった場合、ブロック内ではNothingと評価されて削除されます。

## 保存

デフォルトでは、エイリアスは現在のセッションでのみ有効です。これは一時的なヘルパーや新しいエイリアスをテストするのに便利ですが、エイリアスを有効に活用するには保存しておく必要があります。エイリアスを保存するには、aliasを`--save`(もしくは`-s`)つきで実行します。例えば

```
alias e --save [msg] { echo $msg }
```

エイリアスは起動時の設定に保存され、`config get startup`で確認することができます。`startup`設定がまだ存在していない場合はエラーが表示されます。

config.tomlファイルのエイリアスを直接編集することもできます。`vi`を使う場合は

```
config path | vi $it
```
44 changes: 44 additions & 0 deletions ja/book/coming_from_bash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Bashから来た人向け

注: このテーブルはNu 1.14.1以降を想定しています。

| Bash | Nu | Task |
| ------------- | ------------- | ----- |
| `ls` | `ls` | Lists the files in the current directory |
| `ls <dir>` | `ls <dir>`| Lists the files in the given directory |
| `ls pattern*` | `ls pattern*` | Lists files that match a given pattern |
| `ls -la` | `ls --full` or `ls -f` | List files with all available information |
| `ls -d */` | `ls | where type == Dir` | List directories |
| `find . -name *.rs` | `ls **/*.rs` | Find recursively all files that match a given pattern |
| `cd <directory>` | `cd <directory>` | Change to the given directory |
| `cd` | `cd` | Change to the home directory |
| `mkdir <path>` | `mkdir <path>` | Creates the given path |
| `mkdir -p <path>` | `mkdir <path>` | Creates the given path, creating parents as necessary |
| `touch test.txt` | `touch test.txt` | Create a file |
| `> <path>` | `| save --raw <path>` | Save string into a file |
| `cat <path>` | `open --raw <path>` | Display the contents of the given file |
| | `open <path>` | Read a file as structured data |
| `mv <source> <dest>` | `mv <source> <dest>` | Move file to new location |
| `cp <source> <dest>` | `cp <source> <dest>` | Copy file to new location |
| `cp -r <source> <dest>` | `cp -r <source> <dest>` | Copy directory to a new location, recursively |
| `rm <path>` | `rm <path>` | Remove the given file |
| | `rm -t <path>` | Move the given file to the system trash |
| `rm -rf <path>` | `rm -r <path>` | Recursively removes the given path |
| `chmod` | `<not yet possible>` | Changes the file attributes |
| `date -d <date>` | `echo <date> | str to-datetime -f <format>` | Parse a date ([format documentation](https://docs.rs/chrono/0.4.15/chrono/format/strftime/index.html)) |
| `man <command>` | `help <command>` | Get the help for a given command |
| | `help commands` | List all available commands |
| `command1 && command2` | `command1; command2` | Run a command, and if it's successful run a second |
| `stat $(which git)` | `stat $(which git).path` | Use command output as argument for other command |
| `echo $PATH` | `echo $nu.path` | See the current path |
| `<update ~/.bashrc>` | `config set path [<dir1> <dir2> ...]` | Update PATH permanently |
| `export PATH = $PATH:/usr/other/bin` | `<not yet possible>` | Update PATH temporarily |
| `export` | `echo $nu.env` | List the current environment variables |
| `<update ~/.bashrc>` | `echo $nu.env | insert var value | config set_into env` | Update environment variables permanently |
| `FOO=BAR ./bin` | `FOO=BAR ./bin` | Update environment temporarily |
| `alias s="git status -sb"` | `alias s [] { git status -sb }` | Define an alias temporarily |
| `<update ~/.bashrc>` | `alias --save myecho [msg] { echo Hello $msg }` | Define an alias for all sessions (persist it in startup config) |
| `<update ~/.bashrc>` | `<update nu/config.toml>` | Add and edit alias permanently (for new shells), find path for the file with `config path` |
| `bash -c <commands>` | `nu -c <commands>` | Run a pipeline of commands (requires 0.9.1 or later) |
| `bash <script file>` | `nu <script file>` | Run a script file (requires 0.9.1 or later) |
| `\` | `<not yet possible>` | Line continuation is not yet supported. |
52 changes: 32 additions & 20 deletions ja/book/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
Nuには、見た目や挙動を変更させるための内部的な変数があります。
以下がそのリストです。

| 変数 | | 説明 |
| Variable | Type | Description |
| ------------- | ------------- | ----- |
| path | table of strings | バイナリーを検索するためのPATH |
| completion_mode | "list" or "circular" | 利用する自動補完のモード |
| ctrlc_exit | boolean | ctrl-cを複数回押したときにNuをexitするかどうか |
| disable_table_indexes | boolean | テーブルインデックスカラムを無効にするかどうか |
| edit_mode | "vi" or "emacs" | 行の編集モードを"vi"か"emacs"モードに変更する |
| env | row | 外部コマンドに渡す環境変数 |
| ctrlc_exit | boolean | Ctrl-cを複数回おしたときにNuを終了するかどうか|
| table_mode | "light" or other | 軽量なテーブルを有効にする |
| edit_mode | "vi" or "emacs" | 行編集を"vi"または"emacs"モードに変更する|
| header_align | "center", "right", or other | テーブルのヘッダーの揃え方 |
| key_timeout | integer | editモードのスイッチ時のタイムアウト |
| nonzero_exit_errors | boolean | 外部コマンドが0以外の終了ステータスの場合にエラーを表示するかどうか|
| path | list of strings | バイナリーを検索するPATH |
| startup | list of strings | `alias`のようなnushell起動時に実行するコマンド |
| table_mode | "light" or other | テーブルのモード |
| no_auto_pivot | boolean | 自動で1行のデータをpivotするかどうか |
| skip_welcome_message | boolean | nushell起動時にウェルカムメッセージの表示をスキップするかどうか |


## 利用方法

Expand Down Expand Up @@ -37,11 +46,12 @@ Nuには、見た目や挙動を変更させるための内部的な変数があ

```
> config
━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━
edit_mode │ env │ path │ table_mode
───────────┼────────────────┼──────────────────┼────────────
emacs │ [table: 1 row] │ [table: 10 rows] │ normal
━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━
─────────────────┬──────────────────
completion_mode │ circular
env │ [row 51 columns]
path │ [table 9 rows]
startup │ [table 1 rows]
─────────────────┴──────────────────
```

注: もしまだ変数を設定していない場合、出力が空の場合があります。
Expand Down Expand Up @@ -75,12 +85,8 @@ Nuには、見た目や挙動を変更させるための内部的な変数があ
設定ファイルはデフォルトの場所から読み込まれます。この場所をみつけるには`-path`フラグを利用します。

```
config path
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
<value>
───────────────────────────────────────
/home/nusheller/.config/nu/config.toml
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
> config path
/home/jonathant/.config/nu/config.toml
```

### ファイルから設定を読み込む
Expand Down Expand Up @@ -129,11 +135,17 @@ Nuをログインシェルとして利用するには、`path`と`env`変数を

## プロンプトの設定

現在、プロンプトの設定は[starship](https://github.com/starship/starship)プロンプトサポートつきでNuをインストールすることで可能になります。
プロンプトの設定は`prompt`の値を設定することで行います。
例えば、[starship](https://starshp.rs)を使うには、ダウンロードして次のコマンドを実行します。(0.18.2 and later)

```
config set prompt `echo $(starship prompt)`
```

Nuを再起動すると

```
nushell on 📙 master [$] is 📦 v0.5.1 via 🦀 v1.40.0-nightly
nushell on 📙 master [$] is 📦 v0.18.2 via 🦀 v1.48.0-nightly
```

Starshipは楽しくカラフルで驚くほど強力なプロンプトです。設定するには[starshipのドキュメント](https://starship.rs/config/)の手順にしたがってください。
32 changes: 32 additions & 0 deletions ja/book/environment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 環境変数

外部アプリケーションが使用する環境を制御することはシェルの一般的なタスクです。多くの場合、環境はパッケージ化されて外部のアプリケーション起動時に与えられることで自動的に行われます。しかし時には、アプリケーションが利用する環境変数をより正確に制御したい場合があります。

アプリケーションに送られる現在の環境変数は`$nu.env`の値をechoして確認することができます。

```
> echo $nu.env
──────────────────────────┬──────────────────────────────
COLORTERM │ truecolor
DBUS_SESSION_BUS_ADDRESS │ unix:path=/run/user/1000/bus
DESKTOP_SESSION │ gnome
DISPLAY │ :1
```

環境はNuの設定とNuが実行されている環境から作られます。[設定の章](configuration.md)に記載されている方法で環境を恒久的に更新できます。

コマンドやパイプラインを実行するときに一時的に環境変数を更新することもできます。

```
> with-env [FOO BAR] { echo $nu.env.FOO }
BAR
```

`with-env`コマンドは、環境変数を一時的に与えられた値に設定します(ここでは変数"FOO"に"BAR"という値がセットされます)。ブロックは新しい環境変数が設定された状態で実行されます。

Bashなどにヒントを得た一般的な省略記法も用意されています。上の例は次のように書くことができます。

```
> FOO=BAR echo $nu.env.FOO
BAR
```
23 changes: 18 additions & 5 deletions ja/book/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Dockerを利用してビルド済のコンテナをプルしてくる方法も

## Windows

**Note** NuはWindows 10で動作しますが、現在のところ7/8.1のサポートはありません
**Note** NuはWindows 10で動作しますが、現在のところ7/8.1はサポートされていません

[リリースページ](https://github.com/nushell/nushell/releases)から`.zip`ファイルをダウンロードして、例えば次の箇所に解凍します。

Expand Down Expand Up @@ -38,7 +38,7 @@ Dockerを利用してビルド済のコンテナをプルしてくる方法も

"nu-base"と"nu"のどちらにもバイナリーが含まれますが、nu-baseには`/code`内にソースコードと全ての依存関係も含まれています。

[dockerfiles](https://github.com/nushell/nushell/tree/master/docker)を利用してローカルにコンテナをビルドすることもできます
[dockerfiles](https://github.com/nushell/nushell/tree/master/docker)を利用してローカルでコンテナをビルドすることもできます
ベースイメージをビルドするには:

<<< @/snippets/installation/build_containers_locally_base_image.sh
Expand Down Expand Up @@ -74,7 +74,7 @@ Windowsの場合、Visual Studio Community Editionをインストールすると

Rustがシステムにまだインストールされていない場合は、[rustup](https://rustup.rs/)を利用してRustをインストールする方法がベストです。Rustupは、異なるRustのバージョンのインストールを管理するツールです。

Nuは現在、**最新のstable(1.39 or later)** バージョンのRustを必要とします。
Nuは現在、**最新のstable(1.46 or later)** バージョンのRustを必要とします。
`rustup`で正しいversionを選択するのが良い方法です。
最初に"rustup"を実行すると、インストールするRustのバージョンを尋ねられます。

Expand All @@ -83,7 +83,8 @@ Nuは現在、**最新のstable(1.39 or later)** バージョンのRustを必要
準備ができたら、1を押してからエンターを押します。

もし、`rustup`を経由してRustをインストールしたくない場合、他の方法でもインストールすることができます。(例えば、Linuxディストリビューションのパッケージから)
その場合でもRustの1.39以上のバージョンがインストールされるようにしてください。
その場合でもRustの1.46以上のバージョンがインストールされるようにしてください。

## 依存関係

### Debian / Ubuntu
Expand All @@ -96,6 +97,12 @@ Nuは現在、**最新のstable(1.39 or later)** バージョンのRustを必要

<<< @/snippets/installation/use_rawkey_and_clipboard.sh

### RHEL based distros

"libxcb", "openssl-devel"および"libX11-devel"パッケージをインストールする必要があります。

<<< @/snippets/installation/install_rhel_dependencies.sh

### macOS

[Homebrew](https://brew.sh/)を利用して、"openssl"と"cmake"をインストールしてください。
Expand All @@ -104,7 +111,8 @@ Nuは現在、**最新のstable(1.39 or later)** バージョンのRustを必要

## [crates.io](https://crates.io)からのインストール

必要となる依存関係が準備できたら、Rustコンパイラーに付属している`cargo`を使って、Nuをインストールできます。
必要となる依存関係が準備できたら、Rustコンパイラーに付属している`cargo`を使って、Nuをインストールできます。
cargoはNuとそのソースの依存関係をダウンロードし、ビルドしたあと、実行できるようにcargoのbin pathにインストールします。

<<< @/snippets/installation/cargo_install_nu.sh

Expand All @@ -118,6 +126,7 @@ Nuは現在、**最新のstable(1.39 or later)** バージョンのRustを必要

<<< @/snippets/installation/build_nu_yourself.sh

上で示したすべての依存関係がシステムにあることを確認してください。
インストールが完了すると、`nu`コマンドでNuを実行できます。

<<< @/snippets/installation/crates_run_nu.sh
Expand All @@ -136,6 +145,10 @@ Gitでメインのnushellリポジトリをクローンし、Nuをビルドし

<<< @/snippets/installation/build_nu_from_source_release.sh

Rustに慣れている人は、"run"がデフォルトでビルドを行うのに、なぜ"build"と"run"の両方を行うのか疑問に思うかもしれません。
これはCargoの新しい`default-run`オプションの欠点を回避し、全てのプラグインがビルドされるようにするためですが、将来的には必要なくなるかもしれません。


## ログインシェルとして設定するには

**!!! Nuは開発中なので、日常使いのシェルとしての安定性を欠く可能性があります!!!**
Expand Down
Loading