Create a gist now

Instantly share code, notes, and snippets.

@aarondodd /google-chrome Secret
Created Mar 23, 2018

Embed
What would you like to do?
WSL Google Chrome Wrapper
#!/bin/bash
# Purpose:
# 1. to open local file paths from /mnt/DRV in Windows' Google Chrome
# 2. to translate known mount points (in this example, /home/aaron/addc_g is a DrvFS mount to my ExpanDrive H: for Google Drive)
# Assumes:
# 1. Google chrome is installed in windows
# 2. Google chrome is installed in WSL
# 3. the output of "dir /x c:\" shows the "Program Files (x86)" as "PROGRA~2"
WIN_GOOGLE="/mnt/c/PROGRA~2/Google/Chrome/Application/chrome.exe"
LIN_GOOGLE="google-chrome"
if [[ $1 == /mnt/* ]]
then
#echo "windows"
url=${1:5}
url=$(echo "${url}" | sed 's/^\///' | sed 's/\//\\\\/g' | sed 's/^./\0:/')
eval ${WIN_GOOGLE} "${url}"
elif [[ $1 == /home/aaron/addc_g/* ]]
then
#echo "windows g-drive"
url=${1:19}
url="/h/${url}"
url=$(echo "${url}" | sed 's/^\///' | sed 's/\//\\\\/g' | sed 's/^./\0:/')
eval ${WIN_GOOGLE} "${url}"
elif [[ $1 == http* ]]
then
#echo "windows url"
eval ${WIN_GOOGLE} "$1"
else
#echo "linux"
url=$1
eval ${LIN_GOOGLE} ${url}
fi
#echo $1
#echo ${url}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment