Nushellのソースコードを読んだので少しだけまとめます。
実行時引数
➜ nu -help
nushell 0.5.0
USAGE:
nu [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--debug <debug>...
--develop <develop>...
-l, --loglevel <LEVEL> [possible values: error, warn, info, debug, trace]
-hでhelp表示、-Vでバージョン表示。オプションとして--developと-loglevelと--debugがありますね。(なぜかVSCodeのターミナルに設定するときは--loglevelがrequiredされてた。)
指定がない場合はWarnが設定され、nu本体が実行されます。
コマンド一覧
コマンド一覧はhelp commands
で確認することができます。
> help commands
━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
────┼─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────
0 │ append │ Append the given row to the table
1 │ autoview │ View the contents of the pipeline as a table or list.
2 │ cd │ Change to a new path.
3 │ clip │ Copy the contents of the pipeline to the copy/paste buffer
4 │ config │ Configuration management.
5 │ count │ Show the total number of rows.
6 │ cp │ Copy files.
7 │ date │ Get the current datetime.
8 │ debug │ Debug input fed.
9 │ echo │ Echo the arguments back to the user.
10 │ enter │ Create a new shell and begin at this path.
11 │ env │ Get the current environment.
12 │ exit │ Exit the current shell (or all shells)
13 │ fetch │ Load from a URL into a cell, convert to table if possible (avoid by appending '--raw')
14 │ first │ Show only the first number of rows.
15 │ from-bson │ Parse text as .bson and create table.
16 │ from-csv │ Parse text as .csv and create table
17 │ from-db │ Parse binary data as db and create table.
18 │ from-ini │ Parse text as .ini and create table
19 │ from-json │ Parse text as .json and create table.
20 │ from-sqlite │ Parse binary data as sqlite .db and create table.
21 │ from-ssv │ Parse text as space-separated values and create a table. The default minimum number of spaces counted as a
│ │ separator is 2.
22 │ from-toml │ Parse text as .toml and create table.
23 │ from-tsv │ Parse text as .tsv and create table.
24 │ from-url │ Parse url-encoded string as a table.
25 │ from-xml │ Parse text as .xml and create table.
26 │ from-yaml │ Parse text as .yaml/.yml and create table.
27 │ from-yml │ Parse text as .yaml/.yml and create table.
28 │ get │ Open given cells as text.
29 │ group-by │ Creates a new table with the data from the table rows grouped by the column given.
30 │ help │ Display help information about commands.
31 │ history │ Display command history.
32 │ last │ Show only the last number of rows.
33 │ lines │ Split single string into rows, one per line.
34 │ ls │ View the contents of the current or given path.
35 │ mkdir │ Make directories, creates intermediary directories as required.
36 │ mv │ Move files or directories.
37 │ n │ Go to next shell.
38 │ nth │ Return only the selected row
39 │ open │ Load a file into a cell, convert to table if possible (avoid by appending '--raw')
40 │ p │ Go to previous shell.
41 │ pick │ Down-select table to only these columns.
42 │ pivot │ Pivots the table contents so rows become columns and columns become rows.
43 │ post │ Post content to a url and retrieve data as a table if possible.
44 │ prepend │ Prepend the given row to the front of the table
45 │ pwd │ Output the current working directory.
46 │ reject │ Remove the given columns from the table.
47 │ reverse │ Reverses the table.
48 │ rm │ Remove a file
49 │ save │ Save the contents of the pipeline to a file.
━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
────┼──────────────┼───────────────────────────────────────────────────────────────
50 │ shells │ Display the list of current shells.
51 │ size │ Gather word count statistics on the text.
52 │ skip-while │ Skips rows while the condition matches.
53 │ sort-by │ Sort by the given columns.
54 │ split-column │ Split row contents across multiple columns via the separator.
55 │ split-row │ Split row contents over multiple rows via the separator.
56 │ table │ View the contents of the pipeline as a table.
57 │ tags │ Read the tags (metadata) for values.
58 │ to-bson │ Convert table into .bson text.
59 │ to-csv │ Convert table into .csv text
60 │ to-db │ Convert table to db data
61 │ to-json │ Convert table into .json text
62 │ to-sqlite │ Convert table to sqlite .db binary data
63 │ to-toml │ Convert table into .toml text
64 │ to-tsv │ Convert table into .tsv text
65 │ to-url │ Convert table into url-encoded text
66 │ to-yaml │ Convert table into .yaml/.yml text
67 │ trim │ Trim leading and following whitespace from text data.
68 │ version │ Display Nu version
69 │ where │ Filter table to match the condition.
70 │ which │ Finds a program file.
━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
個々の説明はhelp rm
といった感じで見ることができます。
Ctrl-rで履歴を表示することができます。Enterで実行、tabで編集
Configファイル
configファイルはmacOSでは$HOME/Library/Application Support/nu/config.toml
にあります。他のOSでは分かりませんが、env | get config
でconfig.tomlのパスを調べることができます。
path = ["hoge/huga", "huga/hoge"]
という形式でPathを設定することができます。
envも設定できるが、tomlの書き方がわからない。。テーブルと配列で書いてみたけどクラッシュした。
ちなみに下記のコマンドで直接パスを追加することもできます。
> echo $nu:path | prepend "/my/new/directory" | config --set_into path
> echo $nu:env | insert GREETING hello_world | config --set_into env
でenvに追加できると紹介されているが、insertコマンドがないと怒られてしまう。。
www.jonathanturner.org
いろいろ
プロンプトフォーマット
プロンプトは以下のフォーマットで表示される。
/Users/hoge(master)>
といった形ですね。
let prompt = &format!(
"{}{}> ",
cwd,
match current_branch() {
Some(s) => format!("({})", s),
None => "".to_string(),
}
);
また読んだら追記します。