Skip to content

Instantly share code, notes, and snippets.

@qntmpkts
Created September 17, 2017 17:53
Show Gist options
  • Save qntmpkts/248a6b0261a62f35bc24ed54cc5af9f0 to your computer and use it in GitHub Desktop.
Save qntmpkts/248a6b0261a62f35bc24ed54cc5af9f0 to your computer and use it in GitHub Desktop.
Install Visual Studio Code Insiders in Crouton Chroot (ChromiumOS/ChromeOS)
#!/usr/bin/env sh
_install_vsc() {
echo "Re-entering chroot to complete installation..."
sudo enter-chroot -n ${1} sudo -S sh -c "curl -L https://go.microsoft.com/fwlink/?LinkID=760865 > /tmp/code-insiders.deb; sudo dpkg -i /tmp/code-insiders.deb; sudo apt-get install -f; rm /tmp/code-insiders.deb;";
if [ $? -eq 0 ]; then
echo "Code install script complete.";
else
echo "Code install script failed.";
exit 1;
fi;
}
if [ -z ${1} ]; then
echo "Run script with chroot name as parameter.";
echo "Discovered chroots:\n$(ls /usr/bin/local/chroots)";
exit 1;
fi
_install_vsc ${1}
if [ -e ${HOME}/.bashrc ]; then
code=$( cat ${HOME}/.bashrc |grep "alias code"|grep -v "grep" )
code_alias="alias code=\"sudo enter-chroot -n ${1} -b xiwi -T code-insiders\""
if [ ! -z $code ]; then
echo "Removing any existing 'code' alias from ${HOME}/.bashrc... and replacing with new 'code' alias...";
sed -i.bak "s/alias code=.*/$code_alias/g" ${HOME}/.bashrc;
else
echo "Adding new 'code' alisas to ${HOME}/.bashrc...";
echo $code_alias >> ${HOME}/.bashrc;
fi
unset code
unset code_alias
fi;
echo "Done!\n";
echo "To run Visual Studio Code from now on perform the following steps:\n
1) Press Ctrl+Alt+T on your keyboard to open a crosh shell.
2) Type (without the quotes!) \"shell\" and press return.
3) Type (without the quotes!) \"code\" and press return.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment