Auto source VS environment for cygwin
Command
 - vsshell

Requires
 - cygutils

Description
Start a new shell with VS env, then exit the current shell.
If env exists, Framework Version will be outputted instead.
#!/bin/bash

if [ -n "$FrameworkVersion" ]; then
	alias vsshell='echo "FrameworkVersion $FrameworkVersion"'
	return
fi

BAT_DIR=~/.local/lib/bat
mkdir -p $BAT_DIR

VS_SHELL_BAT=$BAT_DIR/vs-env.bat

function vsshell {
	_SHELL=$( cygpath -w -a $VS_SHELL_BAT )
	cmd /c "$_SHELL"
	exit
}

if [ -f "$VS_SHELL_BAT" ]; then
	_PATH=$( cygpath "$( grep -o "^@REM FILE_PATH: .\+" "$VS_SHELL_BAT" | cut -c 17- )" )
	if [ -f "$_PATH" ]; then
		return
	fi
fi

START_MENU="$( cygpath $ProgramData )/Microsoft/Windows/Start Menu/"

_PATH=$( find "$START_MENU" -name "*Command Prompt*" | grep "Visual Studio" | grep x64 | grep Native | xargs -I % readshortcut % -r | grep -o "\"\([^\"]\+\)\"" )

echo "@echo off" > "$VS_SHELL_BAT"
echo "@REM FILE_PATH: ${_PATH:1:-1}" >> "$VS_SHELL_BAT"
echo "CALL $_PATH" >> "$VS_SHELL_BAT"
echo "START $( where mintty ) -i /Cygwin-Terminal.ico -" >> "$VS_SHELL_BAT"
Workflow
 -> Find the shortcut matching *Command Prompt*Visual Studio, x64 and Native criteria under Start Menu
 -> Read the bat location in that shortcut
 -> Create ~/.local/lib/bat/vs-env.bat. Which will be used to source the VS environment
Profile picture
斟酌 鵬兄
Wed Aug 23 2017 17:27:46 GMT+0000 (Coordinated Universal Time)
Last modified: Wed Aug 23 2017 17:27:53 GMT+0000 (Coordinated Universal Time)
Comments
No comments here.
Do you even comment?
website: 
Not a valid website
Invalid email format
Please enter your email
*Name: 
Please enter a name
Submit
抱歉,Google Recaptcha 服務被牆掉了,所以不能回覆了