Skip to content

Instantly share code, notes, and snippets.

@aarondodd
Created March 23, 2018 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarondodd/913c6316351b11f6c3ea271ee8ce7ab7 to your computer and use it in GitHub Desktop.
Save aarondodd/913c6316351b11f6c3ea271ee8ce7ab7 to your computer and use it in GitHub Desktop.
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