Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dcd29f0

Browse files
committed
Allow specifying alternate VS Code settings dirs
Notably adds support for VS Codium and VS Code Insiders. Resolves coder#34, coder#29
1 parent 7d359fc commit dcd29f0

File tree

3 files changed

+64
-25
lines changed

3 files changed

+64
-25
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ on follow-up connections to the same server.
5151

5252
To disable this feature entirely, pass the `--skipsync` flag.
5353

54+
### Custom settings directories
55+
56+
If you're using an alternate release of VS Code such as VS Code Insiders, you
57+
must specify your settings directories through the `VSCODE_CONFIG_DIR` and
58+
`VSCODE_EXTENSIONS_DIR` environment variables.
59+
60+
The following will make `sshcode` work with VS Code Insiders:
61+
62+
```bash
63+
export VSCODE_CONFIG_DIR="$HOME/.config/Code - Insiders/User"
64+
export VSCODE_EXTENSIONS_DIR="$HOME/.vscode-insiders/extensions"
65+
```
66+
5467
### Sync-back
5568

5669
By default, VS Code changes on the remote server won't be synced back

main.go

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"os/exec"
1212
"os/signal"
1313
"path/filepath"
14-
"runtime"
1514
"strconv"
1615
"strings"
1716
"text/tabwriter"
@@ -66,6 +65,11 @@ func main() {
6665
flag.Usage = func() {
6766
fmt.Printf(`Usage: %v [FLAGS] HOST [DIR]
6867
Start VS Code via code-server over SSH.
68+
69+
Environment variables:
70+
`+vsCodeConfigDirEnv+` use special VS Code settings dir.
71+
`+vsCodeExtensionsDirEnv+` use special VS Code extensions dir.
72+
6973
More info: https://github.com/codercom/sshcode
7074
7175
Arguments:
@@ -336,27 +340,3 @@ func rsync(src string, dest string, sshFlags string, excludePaths ...string) err
336340

337341
return nil
338342
}
339-
340-
func configDir() (string, error) {
341-
var path string
342-
switch runtime.GOOS {
343-
case "linux":
344-
path = os.ExpandEnv("$HOME/.config/Code/User/")
345-
case "darwin":
346-
path = os.ExpandEnv("$HOME/Library/Application Support/Code/User/")
347-
default:
348-
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
349-
}
350-
return filepath.Clean(path), nil
351-
}
352-
353-
func extensionsDir() (string, error) {
354-
var path string
355-
switch runtime.GOOS {
356-
case "linux", "darwin":
357-
path = os.ExpandEnv("$HOME/.vscode/extensions/")
358-
default:
359-
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
360-
}
361-
return filepath.Clean(path), nil
362-
}

settings.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
"runtime"
7+
8+
"golang.org/x/xerrors"
9+
)
10+
11+
const (
12+
vsCodeConfigDirEnv = "VSCODE_CONFIG_DIR"
13+
vsCodeExtensionsDirEnv = "VSCODE_EXTENSIONS_DIR"
14+
)
15+
16+
func configDir() (string, error) {
17+
if env, ok := os.LookupEnv(vsCodeConfigDirEnv); ok {
18+
return os.ExpandEnv(env), nil
19+
}
20+
21+
var path string
22+
switch runtime.GOOS {
23+
case "linux":
24+
path = os.ExpandEnv("$HOME/.config/Code/User/")
25+
case "darwin":
26+
path = os.ExpandEnv("$HOME/Library/Application Support/Code/User/")
27+
default:
28+
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
29+
}
30+
return filepath.Clean(path), nil
31+
}
32+
33+
func extensionsDir() (string, error) {
34+
if env, ok := os.LookupEnv(vsCodeExtensionsDirEnv); ok {
35+
return os.ExpandEnv(env), nil
36+
}
37+
38+
var path string
39+
switch runtime.GOOS {
40+
case "linux", "darwin":
41+
path = os.ExpandEnv("$HOME/.vscode/extensions/")
42+
default:
43+
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
44+
}
45+
return filepath.Clean(path), nil
46+
}

0 commit comments

Comments
 (0)