mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 17:59:11 +08:00
commit
efe64ee6fd
@ -15,6 +15,13 @@
|
||||
* Turn this on in existing Cmder using `clink set history_io 1`
|
||||
* Allow clink disable by setting CMDER_CLINK=0 before starting task
|
||||
|
||||
### Adds
|
||||
|
||||
* Pull Request: [#2072](https://github.com/cmderdev/cmder/pull/2072)
|
||||
* New alias create [alias] [alias command] syntax
|
||||
* Based on [#1750](https://github.com/cmderdev/cmder/pull/1750)
|
||||
* Syntax: `alias create [alias] [alias command]`
|
||||
|
||||
## [1.3.11](https://github.com/cmderdev/cmder/tree/v1.3.11) (2018-12-22)
|
||||
|
||||
### Fixes
|
||||
|
82
vendor/bin/alias.cmd
vendored
82
vendor/bin/alias.cmd
vendored
@ -22,10 +22,15 @@ goto parseargument
|
||||
|
||||
if /i "%currentarg%" equ "/f" (
|
||||
set ALIASES=%~2
|
||||
set _f=%~2
|
||||
shift
|
||||
goto :do_shift
|
||||
) else if /i "%currentarg%" == "/reload" (
|
||||
goto :p_reload
|
||||
) else if "%currentarg%" equ "/H" (
|
||||
goto :p_help
|
||||
) else if "%currentarg%" equ "/h" (
|
||||
goto :p_help
|
||||
) else if "%currentarg%" equ "/?" (
|
||||
goto :p_help
|
||||
) else if /i "%currentarg%" equ "/d" (
|
||||
@ -43,11 +48,31 @@ goto parseargument
|
||||
doskey /macros | %WINDIR%\System32\findstr /b %currentarg%= && exit /b
|
||||
echo insufficient parameters.
|
||||
goto :p_help
|
||||
) else (
|
||||
:: handle quotes within command definition, e.g. quoted long file names
|
||||
) else if "%currentarg%" == "create" (
|
||||
set _x=%*
|
||||
|
||||
set _x=!_x:^^=^^^^!
|
||||
set action=create
|
||||
if ["%_f%"] neq [""] (
|
||||
for /f "tokens=1,2,3,* usebackq" %%G in (`echo !_x!`) do (
|
||||
set _x=%%J
|
||||
)
|
||||
) else (
|
||||
for /f "tokens=1,2,* usebackq" %%G in (`echo !_x!`) do (
|
||||
set _x=%%H %%I
|
||||
)
|
||||
)
|
||||
) else (
|
||||
set _x=%*
|
||||
if ["%_f%"] neq [""] (
|
||||
set _x=!_x:^^=^^^^!
|
||||
for /f "tokens=1,2,* usebackq" %%G in (`echo !_x!`) do (
|
||||
set _x=%%I
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
rem #endregion parseargument
|
||||
|
||||
if "%ALIASES%" neq "%CMDER_ROOT%\config\user_aliases.cmd" (
|
||||
@ -63,18 +88,26 @@ if "%ALIASES%" neq "%CMDER_ROOT%\config\user_aliases.cmd" (
|
||||
)
|
||||
)
|
||||
|
||||
:: validate alias
|
||||
for /f "delims== tokens=1,* usebackq" %%G in (`echo "%_x%"`) do (
|
||||
:: create with multiple parameters
|
||||
if [%action%] == [create] (
|
||||
for /f "tokens=1,* usebackq" %%G in (`echo !_x!`) do (
|
||||
set alias_name=%%G
|
||||
set alias_value=%%H
|
||||
)
|
||||
) else (
|
||||
:: validate alias
|
||||
for /f "delims== tokens=1,* usebackq" %%G in (`echo "!_x!"`) do (
|
||||
set alias_name=%%G
|
||||
set alias_value=%%H
|
||||
)
|
||||
|
||||
:: leading quotes added while validating
|
||||
set alias_name=!alias_name:~1!
|
||||
|
||||
:: trailing quotes added while validating
|
||||
set alias_value=!alias_value:~0,-1!
|
||||
)
|
||||
|
||||
:: leading quotes added while validating
|
||||
set alias_name=%alias_name:~1%
|
||||
|
||||
:: trailing quotes added while validating
|
||||
set alias_value=%alias_value:~0,-1%
|
||||
|
||||
::remove spaces
|
||||
set _temp=%alias_name: =%
|
||||
|
||||
@ -111,21 +144,36 @@ exit /b
|
||||
:p_help
|
||||
echo.Usage:
|
||||
echo.
|
||||
echo. alias [options] [alias=full command]
|
||||
echo. alias [options] [alias=alias command]
|
||||
echo.
|
||||
echo OR
|
||||
echo.
|
||||
echo. alias create [alias] [alias command]
|
||||
echo.
|
||||
echo.Options:
|
||||
echo.
|
||||
echo. Note: Options MUST precede the alias definition.
|
||||
echo.
|
||||
echo. /d [alias] Delete an [alias].
|
||||
echo. /f [macrofile] Path to the [macrofile] you want to store the new alias in.
|
||||
echo. Default: %cmder_root%\config\user_aliases.cmd
|
||||
echo. /reload Reload the aliases file. Can be used with /f argument.
|
||||
echo. Default: %cmder_root%\config\user_aliases.cmd
|
||||
echo.
|
||||
echo. If alias is called with no parameters, it will display the list of existing aliases.
|
||||
echo. If alias is called with no parameters, it will display the list of existing
|
||||
echo. aliases.
|
||||
echo.
|
||||
echo. In the command, you can use the following notations:
|
||||
echo. $* allows the alias to assume all the parameters of the supplied command.
|
||||
echo. $1-$9 Allows you to seperate parameter by number, much like %%1 in batch.
|
||||
echo. $T is the command seperator, allowing you to string several commands together into one alias.
|
||||
echo. For more information, read DOSKEY/?
|
||||
echo. In the alias command, you can use the following notations:
|
||||
echo.
|
||||
echo. ^^^^^^^^%% - %% signs in env vars must be escaped if preserving the variable
|
||||
echo. in he alias is desired. Variables in aliases surrounded by double
|
||||
echo. quotes only require '^^%%' vs '^^^^^^^^%%'
|
||||
echo. $* - allows the alias to assume all the parameters of the supplied
|
||||
echo. command.
|
||||
echo. $1-$9 - Allows you to seperate parameter by number, much like %%1 in
|
||||
echo. batch.
|
||||
echo. $T - Command seperator, allowing you to string several commands
|
||||
echo. together into one alias.
|
||||
echo.
|
||||
echo. For more information, read DOSKEY /?
|
||||
exit /b
|
||||
|
Loading…
Reference in New Issue
Block a user