mirror of
https://github.com/cmderdev/cmder.git
synced 2025-03-12 21:54:38 +08:00
rename /bin/have.bat to /vendor/lib/flag_exists.cmd
Please use %flag_exists% instead of using have
This commit is contained in:
parent
6af44441fe
commit
861f99d64b
12
README.md
12
README.md
@ -105,7 +105,7 @@ Cmder, PowerShell, and Bash tabs all run on top of the Windows Console API and w
|
|||||||
|
|
||||||
You may however, choose to use an external installation of bash, such as Microsoft's [Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) (called WSL) or the [Cygwin](https://cygwin.com/) project which provides POSIX support on windows.
|
You may however, choose to use an external installation of bash, such as Microsoft's [Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) (called WSL) or the [Cygwin](https://cygwin.com/) project which provides POSIX support on windows.
|
||||||
|
|
||||||
⚠ *NOTE:* Mintty tabs use a program called 'mintty' as the terminal emulator that is not based on the Windows Console API, rather it's rendered graphically by ConEmu. Mintty differs from the other tabs in that it supports xterm/xterm-256color TERM types, and does not work with ConEmu settings like color schemes and key bindings. As such, some differences in functionality are to be expected, such as Cmder not being able to apply a system-wide configuration to it.
|
⚠ *NOTE:* Mintty tabs use a program called 'mintty' as the terminal emulator that is not based on the Windows Console API, rather it's rendered graphically by ConEmu. Mintty differs from the other tabs in that it supports xterm/xterm-256color TERM types, and does not work with ConEmu settings like color schemes and key bindings. As such, some differences in functionality are to be expected, such as Cmder not being able to apply a system-wide configuration to it.
|
||||||
|
|
||||||
As a result mintty specific config is done via the '[%USERPROFILE%|$HOME]/.minttyrc' file. You may read more about Mintty and its config file [here](https://github.com/mintty/mintty).
|
As a result mintty specific config is done via the '[%USERPROFILE%|$HOME]/.minttyrc' file. You may read more about Mintty and its config file [here](https://github.com/mintty/mintty).
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ Uncomment and edit the below line in the script to use Cmder config even when la
|
|||||||
|
|
||||||
### Handling with custom arguments when using init.bat
|
### Handling with custom arguments when using init.bat
|
||||||
|
|
||||||
You can pass custom arguments to `init.bat` and use `have.bat` (or `have` for shortcut) to detect it.
|
You can pass custom arguments to `init.bat` and use `%flag_exists%` to detect it.
|
||||||
|
|
||||||
It is useful when you have multiple modes to execute cmder.
|
It is useful when you have multiple modes to execute cmder.
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ to start init.bat with custom argument(`/startNotepad`) and put
|
|||||||
|
|
||||||
```batch
|
```batch
|
||||||
|
|
||||||
call have "/startNotepad" "cmd /c start notepad.exe"`
|
call %flag_exists% "/startNotepad" "cmd /c start notepad.exe"`
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ init.bat
|
|||||||
|
|
||||||
the `notepad.exe` won't be executed.
|
the `notepad.exe` won't be executed.
|
||||||
|
|
||||||
Detailed usage of `have` can be seen by typing `have /?` in cmder.
|
Detailed usage of `%flag_exists%` can be seen by typing `%flag_exists% /?` in cmder.
|
||||||
|
|
||||||
This feature is usually for external execution.
|
This feature is usually for external execution.
|
||||||
|
|
||||||
@ -304,11 +304,11 @@ And here's the related fragment of my `user-profile.cmd`:
|
|||||||
|
|
||||||
```batch
|
```batch
|
||||||
|
|
||||||
call have NOT "/noautorun" "cmd /c start %cmder_root%\bin\vsCode\Code.exe --user-data-dir %vsCodeUserData% --extensions-dir %vsCodeExtensionsDir% %* %vsCodeUserData%\code.code-workspace"
|
call %flag_exists% NOT "/noautorun" "cmd /c start %cmder_root%\bin\vsCode\Code.exe --user-data-dir %vsCodeUserData% --extensions-dir %vsCodeExtensionsDir% %* %vsCodeUserData%\code.code-workspace"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Integrating Cmder with [Hyper](https://github.com/zeit/hyper), [Microsoft VS Code](https://code.visualstudio.com/), and your favorite IDEs
|
### Integrating Cmder with [Hyper](https://github.com/zeit/hyper), [Microsoft VS Code](https://code.visualstudio.com/), and your favorite IDEs
|
||||||
Cmder by default comes with a vendored ConEmu installation as the underlying terminal emulator, as stated [here](https://conemu.github.io/en/cmder.html).
|
Cmder by default comes with a vendored ConEmu installation as the underlying terminal emulator, as stated [here](https://conemu.github.io/en/cmder.html).
|
||||||
|
|
||||||
However, Cmder can in fact run in a variety of other terminal emulators, and even integrated IDEs. Assuming you have the latest version of Cmder, follow the following instructions to get Cmder working with your own terminal emulator.
|
However, Cmder can in fact run in a variety of other terminal emulators, and even integrated IDEs. Assuming you have the latest version of Cmder, follow the following instructions to get Cmder working with your own terminal emulator.
|
||||||
|
9
vendor/init.bat
vendored
9
vendor/init.bat
vendored
@ -310,9 +310,10 @@ if not exist "%initialConfig%" (
|
|||||||
echo :: use this file to run your own startup commands
|
echo :: use this file to run your own startup commands
|
||||||
echo :: use in front of the command to prevent printing the command
|
echo :: use in front of the command to prevent printing the command
|
||||||
echo.
|
echo.
|
||||||
echo :: the next one lines is for "have" shortcut, a custom arguments handler
|
echo :: the next two lines is for "%%flag_exists%%" shortcut, a custom arguments handler
|
||||||
echo :: don't remove it if you need it
|
echo :: don't remove it if you need it
|
||||||
echo set "CMDER_USER_FLAGS=%*"
|
echo set "CMDER_USER_FLAGS=%%*"
|
||||||
|
echo call "%%cmder_root%%\vendor\lib\flag_exists"
|
||||||
echo.
|
echo.
|
||||||
echo :: uncomment this to have the ssh agent load when cmder starts
|
echo :: uncomment this to have the ssh agent load when cmder starts
|
||||||
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
|
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
|
||||||
@ -325,9 +326,9 @@ echo :: you can add your plugins to the cmder path like so
|
|||||||
echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
|
echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
|
||||||
echo.
|
echo.
|
||||||
echo :: arguments in this batch are passed from init.bat, you can quickly parse them like so:
|
echo :: arguments in this batch are passed from init.bat, you can quickly parse them like so:
|
||||||
echo :: more useage can be seen by typing "have /?"
|
echo :: more useage can be seen by typing "%%flag_exists%% /?"
|
||||||
echo.
|
echo.
|
||||||
echo :: have "/customOption" "your custom command"
|
echo :: %%flag_exists%% "/customOption" "your custom command"
|
||||||
echo.
|
echo.
|
||||||
echo @echo off
|
echo @echo off
|
||||||
) >"%initialConfig%"
|
) >"%initialConfig%"
|
||||||
|
45
bin/have.bat → vendor/lib/flag_exists.cmd
vendored
45
bin/have.bat → vendor/lib/flag_exists.cmd
vendored
@ -1,4 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
set "flag_exists=%~dp0flag_exists"
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
if "%~1" equ "" goto :wrongSyntax
|
if "%~1" equ "" goto :wrongSyntax
|
||||||
@ -7,7 +8,7 @@ if not defined CMDER_USER_FLAGS (
|
|||||||
set "CMDER_USER_FLAGS= "
|
set "CMDER_USER_FLAGS= "
|
||||||
)
|
)
|
||||||
|
|
||||||
set "haveBatNOT=false"
|
set "feNOT=false"
|
||||||
goto :parseArgument
|
goto :parseArgument
|
||||||
|
|
||||||
:doShift
|
:doShift
|
||||||
@ -22,13 +23,13 @@ if /i "%currenTarg%" == "/?" (
|
|||||||
) else if /i "%currenTarg%" equ "/h" (
|
) else if /i "%currenTarg%" equ "/h" (
|
||||||
goto :help
|
goto :help
|
||||||
) else if /i "%currenTarg%" equ "NOT" (
|
) else if /i "%currenTarg%" equ "NOT" (
|
||||||
set "haveBatNOT=true"
|
set "feNOT=true"
|
||||||
goto :doShift
|
goto :doShift
|
||||||
) else (
|
) else (
|
||||||
if "%~1" equ "" goto :wrongSyntax
|
if "%~1" equ "" goto :wrongSyntax
|
||||||
if "%~2" equ "" goto :wrongSyntax
|
if "%~2" equ "" goto :wrongSyntax
|
||||||
set "haveBatArgName=%~1"
|
set "feArgName=%~1"
|
||||||
set "haveBatCommand=%~2"
|
set "feCommand=%~2"
|
||||||
goto :detect
|
goto :detect
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,21 +37,21 @@ if /i "%currenTarg%" == "/?" (
|
|||||||
:: to avoid erroneous deteciton like "/do" "/doNOT", both have a "/do"
|
:: to avoid erroneous deteciton like "/do" "/doNOT", both have a "/do"
|
||||||
:: but if it works like "/do " "/doNOT ", "/do " won't match "/doN"
|
:: but if it works like "/do " "/doNOT ", "/do " won't match "/doN"
|
||||||
set "CMDER_USER_FLAGS=%CMDER_USER_FLAGS% "
|
set "CMDER_USER_FLAGS=%CMDER_USER_FLAGS% "
|
||||||
set "haveBatArgName=%haveBatArgName% "
|
set "feArgName=%feArgName% "
|
||||||
:: echo.
|
:: echo.
|
||||||
:: echo %CMDER_USER_FLAGS%
|
:: echo %CMDER_USER_FLAGS%
|
||||||
:: echo %haveBatNOT%
|
:: echo %feNOT%
|
||||||
:: echo %haveBatArgName%
|
:: echo %feArgName%
|
||||||
:: echo %haveBatCommand%
|
:: echo %feCommand%
|
||||||
:: echo.
|
:: echo.
|
||||||
echo %CMDER_USER_FLAGS% | find /i "%haveBatArgName%">nul
|
echo %CMDER_USER_FLAGS% | find /i "%feArgName%">nul
|
||||||
if "%ERRORLEVEL%" == "0" (
|
if "%ERRORLEVEL%" == "0" (
|
||||||
if "%haveBatNOT%" == "false" (
|
if "%feNOT%" == "false" (
|
||||||
call "%haveBatCommand%"
|
call "%feCommand%"
|
||||||
)
|
)
|
||||||
) else (
|
) else (
|
||||||
if "%haveBatNOT%" == "true" (
|
if "%feNOT%" == "true" (
|
||||||
call "%haveBatCommand%"
|
call "%feCommand%"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
exit /b
|
exit /b
|
||||||
@ -63,22 +64,24 @@ echo.
|
|||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:help
|
:help
|
||||||
echo have.bat
|
echo.
|
||||||
echo Handles with custom arguments for cmder's init.bat
|
echo %%flag_exists%%
|
||||||
echo written by xiazeyu, inspired DRSDavidSoft
|
echo.
|
||||||
|
echo Handles with custom arguments for cmder's init.bat.
|
||||||
|
echo written by xiazeyu, inspired DRSDavidSoft.
|
||||||
echo.
|
echo.
|
||||||
echo Usage:
|
echo Usage:
|
||||||
echo.
|
echo.
|
||||||
echo HAVE [NOT] argName command
|
echo %%flag_exists%% [NOT] argName command
|
||||||
echo.
|
echo.
|
||||||
echo NOT Specifies that have.bat should carry out
|
echo NOT Specifies that %%flag_exists%% should carry out
|
||||||
echo the command only if the condition is false.
|
echo the command only if the condition is false.
|
||||||
echo.
|
echo.
|
||||||
echo argName Specifies which argument name is to detect.
|
echo argName Specifies which argument name is to detect.
|
||||||
echo.
|
echo.
|
||||||
echo command Specifies the command to carry out if the
|
echo command Specifies the command to carry out if the
|
||||||
echo argument name is detected. It's recommand to
|
echo argument name is detected. It's recommand to
|
||||||
echo use a pair of double quotation marks to
|
echo use a pair of double quotation marks to
|
||||||
echo wrap your command to avoid exceed expectation.
|
echo wrap your command to avoid exceed expectation.
|
||||||
echo.
|
echo.
|
||||||
echo Examples:
|
echo Examples:
|
||||||
@ -90,7 +93,7 @@ echo Case 1:
|
|||||||
echo.
|
echo.
|
||||||
echo The following command in user-profile.cmd would execute "notepad.exe"
|
echo The following command in user-profile.cmd would execute "notepad.exe"
|
||||||
echo.
|
echo.
|
||||||
echo call have "/startNotepad" "cmd /c start notepad.exe"
|
echo call %%flag_exists%% "/startNotepad" "cmd /c start notepad.exe"
|
||||||
echo.
|
echo.
|
||||||
echo if you pass parameter to init.bat like:
|
echo if you pass parameter to init.bat like:
|
||||||
echo.
|
echo.
|
||||||
@ -100,7 +103,7 @@ echo Case 2:
|
|||||||
echo.
|
echo.
|
||||||
echo The following command in user-profile.cmd would execute "notepad.exe"
|
echo The following command in user-profile.cmd would execute "notepad.exe"
|
||||||
echo.
|
echo.
|
||||||
echo call have NOT "/dontStartNotepad" "cmd /c start notepad.exe"
|
echo call %%flag_exists%% NOT "/dontStartNotepad" "cmd /c start notepad.exe"
|
||||||
echo.
|
echo.
|
||||||
echo UNLESS you pass parameter to init.bat like:
|
echo UNLESS you pass parameter to init.bat like:
|
||||||
echo.
|
echo.
|
Loading…
x
Reference in New Issue
Block a user