Contributing to Open Source projects leads to collaborating with people around the world this is traditionally done via emails or instant messages. But with the rise of extreme programing practices like pair programing being able to remotely share a code editor is a great feature. VS Code has a plugin Live Share that does just that.
Getting Started with Live Share
If you do not have VS Code already installed, you can read our previous article to get started.
<iframe class=”wp-embedded-content” data-secret=”gtciaHbgdV” frameborder=”0″ height=”338″ marginheight=”0″ marginwidth=”0″ sandbox=”allow-scripts” scrolling=”no” security=”restricted” src=”https://fedoramagazine.org/using-visual-studio-code-fedora/embed/#?secret=gtciaHbgdV” title=”“Using Visual Studio Code on Fedora” — Fedora Magazine” width=”600″></iframe>
Installing the Live Share plugin
First let’s install the dependencies the Live Share plugin requires.
$ sudo dnf install openssl-libs krb5-libs libicu zlib gnome-keyring libsecret desktop-file-utils xorg-x11-utils
Once the installation completes, the Live Share plugin is ready to be installed from the Extensions marketplace.
More details on the role of each dependency can be found in the Documentation.
Finally reload VS Code to activate the new plugin.
Start a Collaboration Session
To start a new collaboration session, it requires a project to be open in VS Code, so let’s clone the following git repository and open it.
$ git clone https://github.com/cverna/rss_feed_notifier.git
This repository contains the source code of the following Magazine article.
<iframe class=”wp-embedded-content” data-secret=”3r8ZRr2uMd” frameborder=”0″ height=”338″ marginheight=”0″ marginwidth=”0″ sandbox=”allow-scripts” scrolling=”no” security=”restricted” src=”https://fedoramagazine.org/never-miss-magazines-article-build-rss-notification-system/embed/#?secret=3r8ZRr2uMd” title=”“Never miss a Magazine article — build your own RSS notification system” — Fedora Magazine” width=”600″></iframe>
In VS Code, use the [Ctrl+K, Ctrl+O] combination to select and open the git repository.
Then from the Live Share extension menu start a collaboration session.
Live Share requires its user to sign in so that it can display the identity of the session participants. You can easily sign in using a GitHub account for example.
Ready to collaborate
To start collaborating Live Share provides a link that can be shared with others. You can get this link in you clipboard by clicking on the Invite paticipants … text.
Once one or more participant have joined the session you can start collaborating.
This is where Live Share really shines as it shows clearly which participant is currently editing the file.
It is also possible to follow a participant. This has for effect to open in your editor all the files that the participant you are following opens.
Another feature of Live Share is to share resources like a server, a terminal or even a debugger session. For example it is very easy to share a terminal session and help a participant setting up a development environment, another example would be to share a database server and to inspect the content of a table.
By default the Live Share connection automatically checks if the host machine and the guest machine can communicate directly, if not Live Share uses a relay hosted in the Azure cloud.
It is possible to configure Live Share to use only direct connection between the host and the guest. For that the host machine needs to open a port in the 5990-5999 range and accept inbound local network connections. The guest needs a network route and outbound access to the host on the same port.
Finally set the connection mode to direct in the Live Share settings.
The documentation provides more details on the connectivity options.
Please note that the Live Share extension is available as Public Preview. The extension source code is currently not open source but this should change once the extension is generally available.