File size: 3,069 Bytes
8d756d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Shells in shells

## Working in multiple directories

While it's common to work in one directory, it can be handy to work in multiple places at the same time. For this, Nu offers the concept of "shells". As the name implies, they're a way of running multiple shells in one, allowing you to quickly jump between working directories and more.

To get started, let's enter a directory:

```nu
/home/jonathan/Source/nushell(main)> enter ../book
/home/jonathan/Source/book(main)> ls
────┬────────────────────┬──────┬────────┬─────────────
 #  β”‚ name               β”‚ type β”‚ size   β”‚ modified
────┼────────────────────┼──────┼────────┼─────────────
  0 β”‚ 404.html           β”‚ File β”‚  429 B β”‚ 2 hours ago
  1 β”‚ CONTRIBUTING.md    β”‚ File β”‚  955 B β”‚ 2 hours ago
  2 β”‚ Gemfile            β”‚ File β”‚ 1.1 KB β”‚ 2 hours ago
  3 β”‚ Gemfile.lock       β”‚ File β”‚ 6.9 KB β”‚ 2 hours ago
```

Entering is similar to changing directories (as we saw with the [`cd`](/commands/docs/cd.md) command). This allows you to jump into a directory to work in it. Instead of changing the directory, we now are in two directories. To see this more clearly, we can use the [`shells`](/commands/docs/shells.md) command to list the current directories we have active:

```nu
/home/jonathan/Source/book(main)> enter ../music
/home/jonathan/Source/music(main)> shells
───┬────────┬───────────────────────────────
 # β”‚ active β”‚             path
───┼────────┼───────────────────────────────
 0 β”‚ false  β”‚ /home/jonathan/Source/nushell
 1 β”‚ false  β”‚ /home/jonathan/Source/book
 2 β”‚ true   β”‚ /home/jonathan/Source/music
───┴────────┴───────────────────────────────
```

The [`shells`](/commands/docs/shells.md) command shows us there are three shells: our original "nushell" source directory, "book" directory and "music" directory which is currently active.

We can jump between these shells with the [`n`](/commands/docs/n.md), [`p`](/commands/docs/p.md) and [`g`](/commands/docs/g.md) shortcuts, short for "next", "previous" and "goto":

```nu
/home/jonathan/Source/music(main)> p
/home/jonathan/Source/book(main)> n
/home/jonathan/Source/music(main)> g 0
/home/jonathan/Source/nushell(main)>
```

We can see the directory changing, but we're always able to get back to a previous directory we were working on. This allows us to work in multiple directories in the same session.

## Exiting the shell

You can leave a shell you have [`enter`](/commands/docs/enter.md)ed using the `dexit` command.

You can always quit Nu, even if multiple shells are active, using `exit`.