One of the most important pieces of your development environment is your keyboard shortcuts. If you’re like me, you probably modified some of the defaults to your liking.
Moving your workspace to the cloud means you have to bring your VS Code keyboard shortcuts along with you!
To do this in Coder, all you have to do is add this line to your personalize or install script:
cp -f keybindings.json /home/coder/.local/share/code-server/User/keybindings.json
Note: this assumes you have a file called keybindings.json
at the root of your workspace or dotfiles repo and you’re okay with overwriting the keybindings.json
in your current workspace. (the -f
is for --force
and overwrites the existing file when copying).
For those that want us to walk you through the whole process — start to finish — read on!
Create a dotfiles repository and personalize script
If you’re not familiar with dotfiles, it’s a repo where you get your workflow settings for things like your shell (zsh, bash, etc.), git, and other things.
- Create a repo called
dotfiles
- Add a new file called
install.sh
at the root, make sure it’s executable - Copy this code and paste it into
install.sh
#!/bin/sh
echo "--Running install script"
echo “Hello world!”
Check out the Coder docs to read more about the personalize and install scripts.
Save VS Code Keyboard Shortcuts to dotfiles
The first thing you need to do is save your current keyboard shortcuts from VS Code. To do this, follow these steps inside VS Code:
- Command Palette > "Preferences: Open Keyboard Shortcuts (JSON)"
- Copy everything in this file and save it to a file at the root of your dotfiles repo called
keybindings.json
Commit this and push it up to the remote so we can use it in the next step.
Modify Install Script
Now we need to modify our install script so that it uses our new keybindings.json
and puts it in the right place after building our Workspace.
In your install.sh
script, add this line:
cp -f keybindings.json /home/coder/.local/share/code-server/User/keybindings.json