mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-11 00:39:08 +08:00
commit
bfaa194468
58
README.md
58
README.md
@ -148,7 +148,7 @@ You may find some Monokai color schemes for mintty to match Cmder [here](https:/
|
|||||||
| `/svn_ssh [path to ssh.exe]` | Define `%SVN_SSH%` so we can use git svn with ssh svn repositories. | `%GIT_INSTALL_ROOT%\bin\ssh.exe` |
|
| `/svn_ssh [path to ssh.exe]` | Define `%SVN_SSH%` so we can use git svn with ssh svn repositories. | `%GIT_INSTALL_ROOT%\bin\ssh.exe` |
|
||||||
| `/user_aliases [file path]` | File path pointing to user aliases. | `%CMDER_ROOT%\config\user-liases.cmd` |
|
| `/user_aliases [file path]` | File path pointing to user aliases. | `%CMDER_ROOT%\config\user-liases.cmd` |
|
||||||
| `/v` | Enables verbose output. | not set |
|
| `/v` | Enables verbose output. | not set |
|
||||||
| (custom arguments) | User defined arguments processed by `flag_exists`. Type `%flag_exists% /?` for more useage. | not set |
|
| (custom arguments) | User defined arguments processed by `cexec`. Type `cexec /?` for more useage. | not set |
|
||||||
|
|
||||||
### Cmder Shell User Config
|
### Cmder Shell User Config
|
||||||
Single user portable configuration is possible using the cmder specific shell config files. Edit the below files to add your own configuration:
|
Single user portable configuration is possible using the cmder specific shell config files. Edit the below files to add your own configuration:
|
||||||
@ -247,39 +247,53 @@ Uncomment and edit the below line in the script to use Cmder config even when la
|
|||||||
# CMDER_ROOT=${USERPROFILE}/cmder # This is not required if launched from Cmder.
|
# CMDER_ROOT=${USERPROFILE}/cmder # This is not required if launched from Cmder.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Handling with custom arguments when using init.bat
|
### Customizing user sessions using `init.bat` custom arguments.
|
||||||
|
|
||||||
You can pass custom arguments to `init.bat` and use `%flag_exists%` to detect it.
|
You can pass custom arguments to `init.bat` and use `cexec.cmd` in your `user_profile.cmd` to evaluate these
|
||||||
|
arguments then execute commands based on a particular flag being detected or not.
|
||||||
|
|
||||||
It is useful when you have multiple modes to execute cmder.
|
`init.bat` creates two shortcuts for using `cexec.cmd` in your profile scripts.
|
||||||
|
|
||||||
If you use
|
#### `%ccall%` - Evaluates flags, runs commands if found, and returns to the calling script and continues.
|
||||||
|
|
||||||
```batch
|
|
||||||
|
|
||||||
init.bat /startNotepad
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
ccall=call C:\Users\user\cmderdev\vendor\bin\cexec.cmd
|
||||||
|
```
|
||||||
|
|
||||||
to start init.bat with custom argument(`/startNotepad`) and put
|
Example: `%ccall% /startnotepad start notepad.exe`
|
||||||
|
|
||||||
```batch
|
#### `%cexec%` - Evaluates flags, runs commands if found, and does not return to the calling script.
|
||||||
|
|
||||||
call %flag_exists% "/startNotepad" "start" "notepad.exe"`
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
cexec=C:\Users\user\cmderdev\vendor\bin\cexec.cmd
|
||||||
into `/config/user-profile.cmd`, then `notepad.exe` will be executed, and once you use
|
|
||||||
|
|
||||||
```batch
|
|
||||||
|
|
||||||
init.bat
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
the `notepad.exe` won't be executed.
|
Example: `%cexec% /startnotepad start notepad.exe`
|
||||||
|
|
||||||
To see detailed usage of `%flag_exists%`, type `%flag_exists% /?` in cmder.
|
It is useful when you have multiple tasks to execute `cmder` and need it to initialize
|
||||||
|
the session differently depending on the task chosen.
|
||||||
|
|
||||||
|
To conditionally start `notepad.exe` when you start a specific `cmder` task:
|
||||||
|
|
||||||
|
* Press <kbd>win</kbd>+<kbd>alt</kbd>+<kbd>t</kbd>
|
||||||
|
* Click `+` to add a new task.
|
||||||
|
* Add the below to the `Commands` block:
|
||||||
|
|
||||||
|
```batch
|
||||||
|
|
||||||
|
cmd.exe /k ""%ConEmuDir%\..\init.bat" /startnotepad"
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* Add the below to your `%cmder_root%\config\user_profile.cmd`
|
||||||
|
|
||||||
|
```batch
|
||||||
|
|
||||||
|
%ccall% "/startNotepad" "start" "notepad.exe"`
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
To see detailed usage of `cexec`, type `cexec /?` in cmder.
|
||||||
|
|
||||||
### 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
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@ set "currenArgu=%~1"
|
|||||||
if /i "%currenArgu%" equ "/setPath" (
|
if /i "%currenArgu%" equ "/setPath" (
|
||||||
:: set %flag_exists% shortcut
|
:: set %flag_exists% shortcut
|
||||||
endlocal
|
endlocal
|
||||||
set "flag_exists=%~dp0flag_exists"
|
set "ccall=call %~dp0cexec.cmd"
|
||||||
|
set "cexec=%~dp0cexec.cmd"
|
||||||
) else if /i "%currenArgu%" == "/?" (
|
) else if /i "%currenArgu%" == "/?" (
|
||||||
goto :help
|
goto :help
|
||||||
) else if /i "%currenArgu%" equ "/help" (
|
) else if /i "%currenArgu%" equ "/help" (
|
||||||
@ -54,15 +55,17 @@ set "feFlagName=%feFlagName% "
|
|||||||
echo %CMDER_USER_FLAGS% | find /i "%feFlagName%">nul
|
echo %CMDER_USER_FLAGS% | find /i "%feFlagName%">nul
|
||||||
if "%ERRORLEVEL%" == "0" (
|
if "%ERRORLEVEL%" == "0" (
|
||||||
if "%feNOT%" == "false" (
|
if "%feNOT%" == "false" (
|
||||||
call %feCommand% %feParam%
|
endlocal && call %feCommand% %feParam%
|
||||||
|
exit /b 0
|
||||||
)
|
)
|
||||||
) else (
|
) else (
|
||||||
if "%feNOT%" == "true" (
|
if "%feNOT%" == "true" (
|
||||||
call %feCommand% %feParam%
|
endlocal && call %feCommand% %feParam%
|
||||||
|
exit /b 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
endlocal
|
endlocal
|
||||||
exit /b
|
exit /b 1
|
||||||
|
|
||||||
:wrongSyntax
|
:wrongSyntax
|
||||||
echo The syntax of the command is incorrect.
|
echo The syntax of the command is incorrect.
|
||||||
@ -74,22 +77,22 @@ exit /b
|
|||||||
|
|
||||||
:help
|
:help
|
||||||
echo.
|
echo.
|
||||||
echo %%flag_exists%%
|
echo CExec - Conditional Exec
|
||||||
echo.
|
echo.
|
||||||
echo Handles with custom arguments for cmder's init.bat.
|
echo Handles with custom arguments for cmder's init.bat.
|
||||||
echo written by xiazeyu, inspired DRSDavidSoft.
|
echo written by xiazeyu, inspired DRSDavidSoft.
|
||||||
echo.
|
echo.
|
||||||
echo Usage:
|
echo Usage:
|
||||||
echo.
|
echo.
|
||||||
echo %%flag_exists%% [/setPath] [NOT] flagName command/program [parameters]
|
echo cexec /setPath [NOT] flagName command/program [parameters]
|
||||||
echo.
|
echo.
|
||||||
echo setPath Generate a global varible %%flag_exists%% for
|
echo /setPath Generate a global varibles %%ccall%% and %%cexec%% for
|
||||||
echo quicker use. Following arguments will be ignored.
|
echo quicker use. Following arguments will be ignored.
|
||||||
echo.
|
echo.
|
||||||
echo NOT Specifies that %%flag_exists%% should carry out
|
echo NOT Specifies that cexec should carry out
|
||||||
echo the command only if the flag is missing.
|
echo the command only if the flag is missing.
|
||||||
echo.
|
echo.
|
||||||
echo flagName Specifies which flag name is to detect. It's recommand
|
echo /[flagName] Specifies which flag name is to detect. It's recommand
|
||||||
echo to use a pair of double quotation marks to wrap
|
echo to use a pair of double quotation marks to wrap
|
||||||
echo your flag name to avoid exceed expectation.
|
echo your flag name to avoid exceed expectation.
|
||||||
echo.
|
echo.
|
||||||
@ -104,24 +107,25 @@ echo to wrap your flag name to avoid exceed expectation.
|
|||||||
echo.
|
echo.
|
||||||
echo Examples:
|
echo Examples:
|
||||||
echo.
|
echo.
|
||||||
echo these examples are expected to be writted in /config/user-profile.cmd
|
echo These examples are expected to be written in %cmder_root%/config/user-profile.cmd
|
||||||
echo it will use the environment varible "CMDER_USER_FLAGS"
|
echo CExec evaluates the environment varible "CMDER_USER_FLAGS" and conditionally
|
||||||
|
echo caries out actions based on flags that are passed.
|
||||||
echo.
|
echo.
|
||||||
echo Case 1:
|
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" and continue running the `user_profile.cmd`
|
||||||
echo.
|
echo.
|
||||||
echo call %%flag_exists%% "/startNotepad" "start" "notepad.exe"
|
echo "%ccall%" "/startNotepad" "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.
|
||||||
echo init.bat /startNotepad
|
echo init.bat /startNotepad
|
||||||
echo.
|
echo.
|
||||||
echo Case 2:
|
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" and stop running the `user_profile.cmd`
|
||||||
echo.
|
echo.
|
||||||
echo call %%flag_exists%% NOT "/dontStartNotepad" "start" "notepad.exe"
|
echo "%cexec%" NOT "/dontStartNotepad" "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.
|
10
vendor/init.bat
vendored
10
vendor/init.bat
vendored
@ -7,7 +7,6 @@
|
|||||||
:: !!! Use "%CMDER_ROOT%\config\user_profile.cmd" to add your own startup commands
|
:: !!! Use "%CMDER_ROOT%\config\user_profile.cmd" to add your own startup commands
|
||||||
|
|
||||||
:: Use /v command line arg or set to > 0 for verbose output to aid in debugging.
|
:: Use /v command line arg or set to > 0 for verbose output to aid in debugging.
|
||||||
endlocal
|
|
||||||
set verbose_output=0
|
set verbose_output=0
|
||||||
set debug_output=0
|
set debug_output=0
|
||||||
set max_depth=1
|
set max_depth=1
|
||||||
@ -29,6 +28,7 @@ if not defined CMDER_ROOT (
|
|||||||
:: Remove trailing '\' from %CMDER_ROOT%
|
:: Remove trailing '\' from %CMDER_ROOT%
|
||||||
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"
|
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"
|
||||||
|
|
||||||
|
call "%cmder_root%\vendor\bin\cexec.cmd" /setpath
|
||||||
call "%cmder_root%\vendor\lib\lib_base"
|
call "%cmder_root%\vendor\lib\lib_base"
|
||||||
call "%cmder_root%\vendor\lib\lib_path"
|
call "%cmder_root%\vendor\lib\lib_path"
|
||||||
call "%cmder_root%\vendor\lib\lib_console"
|
call "%cmder_root%\vendor\lib\lib_console"
|
||||||
@ -332,10 +332,6 @@ 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 two lines is for "%%flag_exists%%" shortcut, a custom arguments handler
|
|
||||||
echo :: don't remove it if you need it
|
|
||||||
echo call "%%cmder_root%%/vendor/lib/flag_exists" "/setPath"
|
|
||||||
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"
|
||||||
echo.
|
echo.
|
||||||
@ -347,9 +343,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 "%%flag_exists%% /?"
|
echo :: more useage can be seen by typing "cexec /?"
|
||||||
echo.
|
echo.
|
||||||
echo :: %%flag_exists%% "/customOption" "command/program"
|
echo :: %%ccall%% "/customOption" "command/program"
|
||||||
echo.
|
echo.
|
||||||
echo @echo off
|
echo @echo off
|
||||||
) >"%initialConfig%"
|
) >"%initialConfig%"
|
||||||
|
1
vendor/lib/lib_profile.cmd
vendored
1
vendor/lib/lib_profile.cmd
vendored
@ -44,3 +44,4 @@ exit /b
|
|||||||
)
|
)
|
||||||
popd
|
popd
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user