Created
December 6, 2011 09:38
-
-
Save soren/1437564 to your computer and use it in GitHub Desktop.
An init script for the default "shell" on windows: cmd.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem This is an init script for the default "shell" on windows: cmd. | |
rem | |
rem You can try it out by calling cmd /k c:\path\to\file\.cmdrc.bat | |
rem | |
rem For a more permanent solution do the following: | |
rem | |
rem 1) copy this file to %USERPROFILE% | |
rem 2) Set the AutoRun key like this: | |
rem REGEDIT4 | |
rem [HKEY_CURRENT_USER\Software\Microsoft\Command Processor] | |
rem "AutoRun"="%USERPROFILE%\\dev_setup.bat" | |
rem | |
rem Setting the shortcut key Ctrl-Alt-T for cmd will give a | |
rem neat "Linux" feel. | |
if defined DEV_SETUP_LOADED goto :eof | |
set DEV_SETUP_LOADED=1 | |
doskey sftp=psftp $* | |
doskey scp=pscp $* | |
doskey ssh=putty $* | |
echo. | |
call :find_home c:\progra~2 easyphp* EASY_PHP apache\bin | |
if defined EASY_PHP_HOME path %PATH%;%EASY_PHP_HOME%\mysql\bin | |
call :find_home c:\progra~2\java jdk* JAVA bin | |
call :find_home c:\opt apache-maven-* MAVEN bin | |
call :find_home c:\opt apache-ant-* ANT bin | |
call :find_home c:\opt jboss-as-* JBOSS bin | |
call :find_home c:\opt forge-* FORGE bin | |
echo. | |
echo %DATE% %TIME:~0,-3% | |
echo. | |
if not defined HOME set HOME=%USERPROFILE% | |
if exist %HOME%\bin path %HOME%\bin;%PATH% | |
if exist %HOME%\NUL cd /d %HOME% | |
goto :eof | |
rem ---------------------------------------------------------------------- | |
rem | |
rem find_home | |
rem | |
rem This "subroutine" will look for a directory matching a pattern in a | |
rem given location. If found a <base>_HOME variable will be set to point | |
rem to the found directory. | |
rem | |
rem If a fourth argument is given it should be a directory below the home | |
rem directory we're looking for. If the directory exists it will be added | |
rem the the path. | |
rem | |
rem USAGE: call :find_home dir pattern base [bin] | |
rem | |
rem Example | |
rem | |
rem Let's say we have a Java JDK 1.5 installed in c:\opt. To find it | |
rem and add its bin to path do the following: | |
rem | |
rem call :find_home c:\opt jdk-* JAVA bin | |
rem | |
rem After calling this JAVA_HOME would be c:\opt\jdk1.5.0 and path would | |
rem include c:\opt\jdk1.5.0\bin as the last entry. | |
rem | |
rem ---------------------------------------------------------------------- | |
:find_home | |
for /f "usebackq tokens=4" %%i in (`dir %1\%2^| findstr "<DIR>"`) do set dir=%%i | |
if defined dir ( | |
echo Found %dir% - setting %3_HOME | |
set %3_HOME=%1\%dir% | |
if not x%4 == x ( | |
if exist %1\%dir%\%4\nul path %PATH%;%1\%dir%\%4 | |
) | |
set %3= | |
) | |
goto :eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment