This repository was archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcode-server.sh
executable file
·185 lines (176 loc) · 4.29 KB
/
code-server.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
# Upgrade script
function upgrade() {
# Read configuration file
. /opt/pojde/preferences/preferences.sh
# Change the password to the new value
CONFIG_FILE=/opt/pojde/code-server/code-server.yaml
cat <<EOT >$CONFIG_FILE
bind-addr: 127.0.0.1:38001
auth: password
password: "${POJDE_PASSWORD}"
EOT
# Create the config dir
CONFIG_DIR=/home/${POJDE_USERNAME}/.local/share/code-server/User/
mkdir -p ${CONFIG_DIR}
# Add web-optimized shortcuts
cat <<EOT >${CONFIG_DIR}/keybindings.json
[
{
"command": "editor.action.marker.nextInFiles",
"keybinding": "alt+p",
"when": "editorFocus && !editorReadonly",
"resolved": [
{
"key": {
"code": "KeyP",
"keyCode": 80,
"easyString": "p"
},
"ctrl": false,
"shift": false,
"alt": true,
"meta": false
}
],
"scope": 1,
"key": "alt+p"
},
{
"command": "file.rename",
"keybinding": "alt+r",
"context": "navigatorActive",
"resolved": [
{
"key": {
"code": "KeyR",
"keyCode": 82,
"easyString": "r"
},
"ctrl": false,
"shift": false,
"alt": true,
"meta": false
}
],
"scope": 1,
"key": "alt+r"
},
{
"command": "editor.action.rename",
"keybinding": "alt+r",
"when": "editorHasRenameProvider && editorTextFocus && !editorReadonly",
"resolved": [
{
"key": {
"code": "KeyR",
"keyCode": 82,
"easyString": "r"
},
"ctrl": false,
"shift": false,
"alt": true,
"meta": false
}
],
"scope": 1,
"key": "alt+r"
},
{
"command": "editor.action.goToReferences",
"keybinding": "alt+i",
"when": "editorHasReferenceProvider && editorTextFocus && !inReferenceSearchEditor && !isInEmbeddedEditor",
"key": "alt+i"
},
{
"key": "alt+w",
"command": "workbench.action.closeActiveEditor"
},
{
"key": "shift+alt+p",
"command": "workbench.action.showCommands"
},
{
"key": "ctrl+shift+\`",
"command": "workbench.action.terminal.new"
},
{
"key": "alt+t",
"command": "workbench.action.showAllSymbols"
},
{
"key": "ctrl+enter",
"command": "workbench.action.debug.start",
"when": "debuggersAvailable && debugState != 'initializing' && editorFocus"
},
{
"key": "ctrl+shift+c",
"command": "-workbench.action.terminal.new"
}
]
EOT
# Add web-optimized configuration
cat <<EOT >${CONFIG_DIR}/settings.json
{
"editor.autoSave": "on",
"keyboard.dispatch": "keyCode",
"sqltools.useNodeRuntime": true,
"git.pullTags": false,
"git.autofetch": true,
"jest.autoEnable": false,
"markdown-preview-enhanced.previewTheme": "none.css",
"omnisharp.enableImportCompletion": true,
"omnisharp.organizeImportsOnFormat": true,
"omnisharp.enableRoslynAnalyzers": true,
"terminal.integrated.gpuAcceleration": "off",
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"typescript": "typescriptreact"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[dockerfile]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
}
}
EOT
# Fix permissions for user
chown -R ${POJDE_USERNAME} /home/${POJDE_USERNAME}/.local/
# Enable & restart the services
if [ "${POJDE_OPENRC}" = 'true' ]; then
rc-service code-server restart
rc-update add code-server default
else
systemctl enable "code-server@${POJDE_USERNAME}"
systemctl restart "code-server@${POJDE_USERNAME}"
fi
}
# Refresh script
function refresh() {
# Read configuration file
. /opt/pojde/preferences/preferences.sh
# Remove extensions
rm -rf /home/${POJDE_USERNAME}/.local/share/code-server/extensions/*
}