commit c9d0de262c91b1cdabaef0e7752d90c5602f93bb
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2017-08-23T14:41:01Z |
| subject | Added alias for initializing vs environment |
commit c9d0de262c91b1cdabaef0e7752d90c5602f93bb
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2017-08-23T14:41:01Z
Added alias for initializing vs environment
---
bash/bashrc/package.sh | 8 ++++++--
bash/bashrc/sources/11_vs_env | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/bash/bashrc/package.sh b/bash/bashrc/package.sh
index f69e5a5..1595e8f 100644
--- a/bash/bashrc/package.sh
+++ b/bash/bashrc/package.sh
@@ -1,16 +1,20 @@
#!/bin/bash
+IS_CYGWIN=false
case $( uname -a | awk '{ print $1 }' ) in
Darwin) # although this is deprecated, Mac still use it
PERM="+111"
;;
# Linux) ;& // Fall through does not support in OS X
- # CYGWIN~) ;&
+ CYGWIN*)
+ PERM="/111"
+ IS_CYGWIN=true
+ ;;
*)
PERM="/111"
;;
esac
-
+
function __func_head() {
echo "Usage:" ${FUNCNAME[1]} $1
}
diff --git a/bash/bashrc/sources/11_vs_env b/bash/bashrc/sources/11_vs_env
new file mode 100755
index 0000000..1b361bc
--- /dev/null
+++ b/bash/bashrc/sources/11_vs_env
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+if ! $IS_CYGWIN; then
+ return
+fi
+
+echo $PATH | grep -q MSBuild
+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
+ return
+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 "CALL $_PATH" >> "$VS_SHELL_BAT"
+echo "START $( where mintty ) -i /Cygwin-Terminal.ico -" >> "$VS_SHELL_BAT"