Skip to content

Instantly share code, notes, and snippets.

@patroza
Created July 5, 2017 07:53
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 patroza/328caba17e98bf14e38eccc447fd80c2 to your computer and use it in GitHub Desktop.
Save patroza/328caba17e98bf14e38eccc447fd80c2 to your computer and use it in GitHub Desktop.
#!/bin/bash
command=`basename "$0"`
run-windows-command "$command" "$@"
#!/bin/bash
command=`basename "$0"`
run-windows-command "$command" "$@"
#!/bin/bash
command="$1"
commands="chcp 437"
found=""
windowsfound=""
upsearch () {
slashes=${PWD//[^\/]/}
directory="$PWD"
windowsdirectory=directory
for (( n=${#slashes}; n>0; --n ))
do
test -e "$directory/.envrc" && windowsfound="$windowsdirectory" && found="$directory" && return
windowsdirectory="..\\"
directory="$directory/.."
done
}
upsearch
if [ "$found" = "$PWD" ]; then
found="."
windowsfound="."
fi
if [ "$found" ]; then
sed -e 's/export/set/g' $found/.envrc | sed 's/#/REM/g' | sed "s/'//g" > "$found/.env.bat"
commands+=" && $windowsfound\.env.bat"
fi
commands+=" && "
commands+=$command
commands+=" ${@:2}"
echo $commands
/mnt/c/Windows/System32/cmd.exe /c $commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment