Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit fa96dc1

Browse files
committed
Allow specifying alternative VS Code settings dirs
Notably adds support for VS Codium and VS Code insiders. Resolves #34, #29
1 parent 302943d commit fa96dc1

File tree

3 files changed

+63
-25
lines changed

3 files changed

+63
-25
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ 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 alternative release of VS Code such as VS Code Insiders, you
57+
will need to specify your configuration directory through the `VSCODE_CONFIG_DIR`
58+
environment variable.
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+
```
65+
5466
### Sync-back
5567

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

main.go

+5-25
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
"time"
@@ -36,6 +35,11 @@ func main() {
3635
fmt.Printf(`Usage: [-skipsync] %v HOST [DIR] [SSH ARGS...]
3736
3837
Start code-server over SSH.
38+
39+
Environment variables:
40+
`+vsCodeConfigDirEnv+` use special VS Code settings dir.
41+
`+vsCodeExtensionsDirEnv+` use special VS Code extensions dir.
42+
3943
More info: https://github.com/codercom/sshcode
4044
`, os.Args[0],
4145
)
@@ -301,27 +305,3 @@ func rsync(src string, dest string, sshFlags string, excludePaths ...string) err
301305

302306
return nil
303307
}
304-
305-
func configDir() (string, error) {
306-
var path string
307-
switch runtime.GOOS {
308-
case "linux":
309-
path = os.ExpandEnv("$HOME/.config/Code/User/")
310-
case "darwin":
311-
path = os.ExpandEnv("$HOME/Library/Application Support/Code/User/")
312-
default:
313-
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
314-
}
315-
return filepath.Clean(path), nil
316-
}
317-
318-
func extensionsDir() (string, error) {
319-
var path string
320-
switch runtime.GOOS {
321-
case "linux", "darwin":
322-
path = os.ExpandEnv("$HOME/.vscode/extensions/")
323-
default:
324-
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
325-
}
326-
return filepath.Clean(path), nil
327-
}

settings.go

+46
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)