Most of the terraform labs and some others use a VSCode editor embedded in the browser for coding exercises. Opening the terminal and getting copy and paste to work can be a challenge!
This page sets out how to solve this issue. It will be expanded as information about other browsers and operating systems is gathered, however as with all labs, the recommended browser is Chrome.
- VSCode Lab Terminal
- Chrome Settings
- Open Terminal
- Copy/Paste to Terminal
- The terminal I had open closed on me!
- How to add folders to the workspace
This is the layout of the terminal for labs that use VSCode
- Explorer pane
- Editor Pane
- Integrated terminal. If this is not showing, see Open Terminal below.
Firstly, you must ensure that kodekloud.com
and all subdomains have access to the clipboard.
- Open
Settings
- Navigate to
Privacy and Security
from the menu on the left - Click on
Site Settings
- Under
Permissions
(Location, Camera etc.), click onAdditional Permissions
- Find
Clipboard
- In the
Allowed to see your clipboard
section, pressAdd
button - Enter
[*.]kodekloud.com
in the Add dialog, and pressAdd
button.
This much should permit you to copy and paste in the code editor windows.
On any system, the terminal my be opened from the Command Palette (normally CTRL + SHIFT + P
). If that key combination doesn't work, right click on the editor window and Command Palette should be a selection on there.
In the command palette that opens at the top, start typing Terminal: Create New Integrated Terminal
- you should see it appear in the drop down long before you complete typing the above command. Select it from there
To open a new terminal using shortcut keys, press:
CTRL + `
CTRL + SHIFT + `
Or
CTRL + SHIFT + '
To copy/paste to the integrated terminal window, we must use shortcut keys. If you try to use the mouse, you will see Unable to read from the browser's clipboard
error.
- Copy -
CTRL + C
- Paste -
SHIFT + INSERT
- Copy -
COMMAND + C
- Paste -
COMMAND + SHIFT + V
This requires further validation and is based on the input of one person who reports the following:
Open the lab in a new browser window, then CTRL + C
and CTRL + V
should work in the terminal.
Please post in Discord on your own experiences with using VSCode labs in Linux OS.
This happens, often after a "Setting things up..." between questions. Simply open it again with the key sequence above, then check the list of existing terminals in the list indicated in the screenshot below. Click on each of these till you recover the terminal you want.
Note that if you are using a small monitor, or you have narrowed the width of your browser, then the list of terminals at the side may instead appear as a drop list above the integrated terminal.
In some courses e.g. the Hashicorp Vault Associate, you will need to edit files in directories other than /root
. You could do this by running vi
in the VSCode terminal window, but it's nicer to be able to use VSCode.
Using the Vault course as an example where it's necessary to edit files in the directory /etc/vault.d
, here is how to set that up...
- Right click in the Explorer pane.
- Select
Add Folder to Workspace...
from the menu. This will open a drop-down list showing the file system. - In the editor box above this list, enter the folder e.g.
/etc/vault.d
in the box and press the blue OK button. After a couple of seconds it will reload and you should see the additional folder in the explorer pane.
Note that when you open the integrated terminal after adding folders, it will ask you which of these folders to open the terminal on. You should select the one that was there at the beginning (ususally root
).