File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,35 @@ job unfreeze 1
9696# we're back in vim
9797```
9898
99+ ## Communicating between jobs
100+
101+ Data can be sent to a job using ` job send <id> ` , and the job can receive it using ` job recv ` :
102+
103+ ``` nu
104+ let jobId = job spawn {
105+ job recv | save sent.txt
106+ }
107+
108+ 'hello from the main thread' | job send $jobId
109+
110+ sleep 1sec
111+
112+ open sent.txt
113+ # => hello from the main thread
114+ ```
115+
116+ The main thread has a job ID of 0, so you can also send data in the other direction:
117+
118+ ``` nu
119+ job spawn {
120+ sleep 1sec
121+ 'Hello from a background job' | job send 0
122+ }
123+
124+ job recv
125+ # => Hello from a background job
126+ ```
127+
99128## Exit Behavior
100129
101130Unlike many other shells, Nushell jobs are ** not** separate processes,
You can’t perform that action at this time.
0 commit comments