Create a gist now

Instantly share code, notes, and snippets.

@VonC /senv.bat
Last active Oct 7, 2015

Settings for a good development environment for Go on Windows or for programs in general Include chocolatey for easy software installation
@echo off
REM if corporate environment, set your proxy
REM set HTTP_PROXY=http://username:password@proxy.corp:port
REM set HTTPS_PROXY=http://username:password@proxy.corp:port
REM set NO_PROXY=.corp,localhost,127.0.0.1,%USERDOMAIN%
set HOME=%HOMEDRIVE%%HOMEPATH%
REM if corporate environment, set your HOME to an *external* backed-up drive
REM set HOME=Z:\
if not exist P:\ subst P: %HOME%\prog
REM if local dev only
rem if not exist P:\ subst P: %HOMEDRIVE%%HOMEPATH%\prog
rem if not exist P:\ subst P: %HOMEDRIVE%%HOMEPATH%\Documents\prog
rem if not exist P:\ subst P: %HOMEDRIVE%%HOMEPATH%\My Documents\prog
REM from http://stackoverflow.com/questions/7949956/git-diff-not-working-terminal-not-fully-functional
set term=msys
REM Make your HOME as small as possible (especially if %HOME% is your profile):
REM %PRG%: all the executble and installations (big, can be re-installed)
REM %HOME%\prog: all the data (smaller, need to be backed up)
set PRG=C:\prog
set GITROOT=%PRG%\git\PortableGit-1.8.0-preview20121022
set HGROOT=%PRG%\hg\Mercurial2.4.0
set GOPATH=%HOME%\prog\go\projects
set GOROOT=%PRG%\go\go1.0.3.windows-amd64
call:cleanAddPath PATH "%GITROOT%\bin"
call:cleanAddPath PATH "%HGROOT%"
call:cleanAddPath PATH "%GOROOT%\bin"
call:cleanAddPath PATH "%GOPATH%\bin"
echo.%PATH%
doskey gl=git lg -20 --branches
doskey gla=git lg -20 --branches --all
# See more at: http://chocolatey.org/#sthash.TLzTeLAK.dpuf
doskey cinstc=@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
doskey cupc=cup chocolatey
set SUBLIMEROOT=%PRG%\Sublime_Text_2.0.1_x64
if not exist "%SUBLIMEROOT%\Data\Packages" md %SUBLIMEROOT%\Data\Packages
set GOSUBLIMEROOT=%SUBLIMEROOT%\Data\Packages\GoSublime
if not exist "%GOSUBLIMEROOT%" git clone https://github.com/DisposaBoy/GoSublime "%GOSUBLIMEROOT%"
git --git-dir="%GOSUBLIMEROOT%/.git" --work-tree="%GOSUBLIMEROOT%" pull origin master
REM http://stackoverflow.com/questions/10438508/error6-while-trying-to-use-sublime-text-to-msbuild
REM avoid the "[Error 6] The handle is invalid" or "[Error 6] Le descripteur est invalide"
doskey gst=start "Sublime Text 2" "%SUBLIMEROOT%\sublime_text.exe" $*
set GOIDEROOT=%PRG%\go\liteide
doskey gid=start "GO IDE" "%GOIDEROOT%\bin\liteide.exe" $*
doskey npp="C:\Program Files (x86)\Notepad++\notepad++.exe" $*
REM if you have clearcase
REM doskey ct=cleartool $*
REM doskey mt=multitool $*
call:cleanAddPath PATH "%PRG%\Gow\bin"
goto end
REM from http://stackoverflow.com/questions/12020152/how-to-keep-the-value-of-a-variable-outside-a-windows-batch-script-which-uses
:cleanAddPath -- remove %~2 from %~1, add it at the end of %~1
SETLOCAL ENABLEDELAYEDEXPANSION
set P=!%~1!
set P=!P:%~2=!
set P=!P:;;=;!
set P=!P!;%~2
set P=!P:;;=;!
(ENDLOCAL & REM.-- RETURN VALUES
SET "%~1=%P%"
)
exit /b
:end
@VonC
Owner

set term=msys will avoid the msysgit error "Terminal is not fully functional" warning (http://code.google.com/p/msysgit/issues/detail?id=184)

@VonC
Owner

GOPATH must reference a path where there are the directories src, pkg, bin.

@VonC
Owner

Starting 565eaa, this won't pollute your %PATH% with multiple duplicated paths.

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