You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ides/configuring-emacs-tramp.md
+30-12Lines changed: 30 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -10,27 +10,42 @@ coder config-ssh
10
10
11
11
Then you can connect to your workspace by its name in the format: `coder.<name>`.
12
12
13
-
In Emacs type `C-x d` and then input: `/ssh:coder.<name>:` and hit enter. This will open up Dired on the workspace's home directory.
13
+
In Emacs type `C-x d` and then input: `/-:coder.<name>:` and hit enter. This will open up Dired on the workspace's home directory.
14
+
15
+
### Using SSH
16
+
By default Emacs TRAMP is setup to use SCP to access files on the Coder workspace instance. However you might want to use SSH if you have a jumpbox or some other complex network setup.
17
+
18
+
To do so set the following in your Emacs `init.el` file:
19
+
20
+
```lisp
21
+
(setq tramp-default-method "ssh")
22
+
```
23
+
24
+
Then when you access the workspace instance via `/-:coder.<name>` Emacs will use SSH. Setting `tramp-default-method` will also tell `ansi-term` mode the correct way to access the remote when directory tracking.
14
25
15
26
## Directory Tracking
16
27
### `ansi-term`
17
28
If you run your terminal in Emacs via `ansi-term` then you might run into a problem where while SSH-ed into a workspace Emacs will not change its `default-directory` to open files in the directory your shell is in.
18
29
19
30
To fix this:
20
31
21
-
1. In your Emacs `init.el` file add:
22
-
```lisp
23
-
(setq tramp-default-method "ssh")
24
-
```
25
-
2. Then on your Coder workspace instance be sure to set the hostname to the `coder.<name>` format:
26
-
```bash
27
-
hostname coder.<name>
32
+
1. In your workspace Terraform template be sure to add the following:
33
+
```hcl
34
+
data "coder_workspace" "me" {
35
+
}
36
+
37
+
resource "coder_agent" "main" {
38
+
# ...
39
+
env {
40
+
name = "CODER_WORKSPACE_NAME"
41
+
value = data.coder_workspace.me.name
42
+
}
43
+
}
28
44
```
29
-
This can also be done in the workspace Terraform template by setting workspace instance's hostname to the data `coder_workspace.name` attribute. How this is done depends on how the instance is provisioned.
30
-
3. Next in the shell profile file on the workspace (ex., `~/.bashrc`) add the following:
45
+
2. Next in the shell profile file on the workspace (ex., `~/.bashrc` for Bash and `~/.zshrc` for Zsh) add the following:
Ansi Term expects the terminal running inside of it to send escape codes to inform Emacs of the hostname, user, and working directory. The above code sends these escape codes and associated data whenever the terminal logs in and whenever the directory changes. The expression in step 1 lets Emacs know that you are accessing the hostname these escape codes announce via SSH.
71
+
Ansi Term expects the terminal running inside of it to send escape codes to inform Emacs of the hostname, user, and working directory. The above code sends these escape codes and associated data whenever the terminal logs in and whenever the directory changes.
72
+
73
+
### `eshell`
74
+
The `eshell` mode will perform directory tracking by default, no additional configuration is needed.
0 commit comments