mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 17:59:11 +08:00
79fbae0854
Add bin/unalias.bat to perform the opposite action of alias.bat. Removes a given alias from the current shell environment and the aliases file. Fixes issue #281.
29 lines
591 B
Batchfile
29 lines
591 B
Batchfile
@echo off
|
|
if ["%1"] == ["/?"] goto:p_help
|
|
if ["%1"] == [""] echo Insufficient parameters. & goto:p_help
|
|
|
|
setlocal
|
|
|
|
:: Check if alias exists
|
|
doskey /macros | findstr /b %1= >NUL || goto :p_not_found
|
|
|
|
:: Remove alias from current shell
|
|
doskey %1=
|
|
|
|
:: Remove alias from aliases file
|
|
copy /y "%CMDER_ROOT%\config\aliases" "%TEMP%\aliases.prev" >NUL
|
|
type "%TEMP%\aliases.prev" | findstr /b /v %1= > "%CMDER_ROOT%\config\aliases"
|
|
echo Alias removed
|
|
|
|
endlocal
|
|
goto:eof
|
|
|
|
:p_not_found
|
|
echo Alias not defined.
|
|
goto:eof
|
|
|
|
:p_help
|
|
echo.Usage:
|
|
echo. unalias name
|
|
echo. For more information, read DOSKEY/?
|