Skip to content

Instantly share code, notes, and snippets.

@valin4tor
Last active March 13, 2021 10:34
Show Gist options
  • Save valin4tor/87bda8a6cdc1136df3d4469fd454c16d to your computer and use it in GitHub Desktop.
Save valin4tor/87bda8a6cdc1136df3d4469fd454c16d to your computer and use it in GitHub Desktop.
Chrome WSL wrapper script for Cypress (place in /usr/bin/chrome)
#!/bin/bash
if [ "$1" == "--version" ]; then
version=$(reg.exe query 'HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon' /v version | grep version)
echo $version | sed -r -e 's/version\s+REG_SZ\s+/Google Chrome /'
exit
fi
userprofile=$(cmd.exe /C 'echo %userprofile%' | tr -d '\r\n')
cypress_folder="$HOME/.config/Cypress"
if [ -d $cypress_folder ] && [ ! -L $cypress_folder ]; then
mv $cypress_folder "$(wslpath $userprofile)/Cypress"
ln -s "$(wslpath $userprofile)/Cypress" $cypress_folder
fi
args=${@//$cypress_folder/$userprofile\/Cypress}
exec winrun chrome $args
@valin4tor
Copy link
Author

valin4tor commented May 4, 2019

Installation:

  1. Install my winrun script to work around a WSL issue
  2. Install the Cypress dependencies on your WSL distro
  3. Install and run an X server for Windows, e.g. VcXsrc
  4. Put the following in your .bashrc: export DISPLAY=:0.0 (if necessary, modify the number to suit your X server configuration)
  5. Save this Gist, or copy its contents, to /usr/bin/chrome in your WSL distro
  6. Make the file executable, e.g. sudo chmod +x /usr/bin/chrome

Usage:

  • Just use Cypress like you normally would in Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment