mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-13 11:19:10 +08:00
commit
052ab118e2
@ -1,8 +1,13 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
set ALIASES=%CMDER_ROOT%\config\aliases
|
set ALIASES=%CMDER_ROOT%\config\aliases
|
||||||
|
setlocal
|
||||||
|
:: handle quotes within command definition, e.g. quoted long file names
|
||||||
|
set _x="%*"
|
||||||
|
set _x=%_x:"=%
|
||||||
|
|
||||||
if ["%*"] == [""] echo Use /? for help & echo. & goto :p_show
|
:: check command usage
|
||||||
|
if ["%_x%"] == [""] echo Use /? for help & echo. & goto :p_show
|
||||||
if ["%1"] == ["/?"] goto:p_help
|
if ["%1"] == ["/?"] goto:p_help
|
||||||
if ["%1"] == ["/reload"] goto:p_reload
|
if ["%1"] == ["/reload"] goto:p_reload
|
||||||
:: /d flag for delete existing alias
|
:: /d flag for delete existing alias
|
||||||
@ -13,20 +18,18 @@ if ["%2"] == [""] (
|
|||||||
echo Insufficient parameters. & goto:p_help
|
echo Insufficient parameters. & goto:p_help
|
||||||
)
|
)
|
||||||
|
|
||||||
::validate alias
|
:: validate alias
|
||||||
setlocal
|
for /f "delims== tokens=1" %%G in ("%_x%") do set alias=%%G
|
||||||
for /f "delims== tokens=1" %%G in ("%*") do set _temp2=%%G
|
set _temp=%alias: =%
|
||||||
|
|
||||||
set _temp=%_temp2: =%
|
if not ["%_temp%"] == ["%alias%"] (
|
||||||
|
|
||||||
if not ["%_temp%"] == ["%_temp2%"] (
|
|
||||||
echo Your alias name can not contain a space
|
echo Your alias name can not contain a space
|
||||||
endlocal
|
endlocal
|
||||||
goto:eof
|
goto:eof
|
||||||
)
|
)
|
||||||
|
|
||||||
:: replace already defined alias
|
:: replace already defined alias
|
||||||
findstr /b /v /i "%_temp%=" "%ALIASES%" >> "%ALIASES%.tmp"
|
findstr /b /v /i "%alias%=" "%ALIASES%" >> "%ALIASES%.tmp"
|
||||||
echo %* >> "%ALIASES%.tmp" && type "%ALIASES%.tmp" > "%ALIASES%" & @del /f /q "%ALIASES%.tmp"
|
echo %* >> "%ALIASES%.tmp" && type "%ALIASES%.tmp" > "%ALIASES%" & @del /f /q "%ALIASES%.tmp"
|
||||||
doskey /macrofile="%ALIASES%"
|
doskey /macrofile="%ALIASES%"
|
||||||
endlocal
|
endlocal
|
||||||
|
Loading…
Reference in New Issue
Block a user