Skip to content

Instantly share code, notes, and snippets.

@alexaandrov
Last active April 11, 2019 07:59
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 alexaandrov/b0408ef44bc78d87b8f3e922937569cf to your computer and use it in GitHub Desktop.
Save alexaandrov/b0408ef44bc78d87b8f3e922937569cf to your computer and use it in GitHub Desktop.
WSL for vagrant in git bash
# Convert path from windows to linux
function lpwd()
{
pwd=$(pwd)
windowsHome=$(echo $HOME)
linuxHome="~"
lpwd=${pwd/$windowsHome/$linuxHome}
echo $lpwd
}
# WSL emulation for vagrant
function wsl()
{
pwd=$(lpwd)
case $1 in
"")
command="cd $pwd; /bin/bash"
;;
*)
command="cd $pwd; $@"
;;
esac
eval "ssh -t vagrant '$command'"
}
@alexaandrov
Copy link
Author

user@pc MINGW64 ~/
$ python --version
Python 3.7.2

user@pc MINGW64 ~/
$ wsl python --version
Python 2.7.5
Connection to localhost closed.

user@pc MINGW64 ~/Projects/wsl
$ ls
wsl.sh

user@pc MINGW64 ~/Project/wsl
$ wsl ls
wsl.sh
Connection to localhost closed.

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