-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: How to start cmder with a command #457
Comments
Hi, @echo off
set CMDER_ROOT=%~dp0
start %CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.exe /icon "%CMDER_ROOT%\cmder.exe" /title Cmder /loadcfgfile "%CMDER_ROOT%\config\ConEmu.xml" /cmd cmd /k "%CMDER_ROOT%\vendor\init.bat cd %CD% && %~1" then call this .bat with your command:
I hope this helps you :) |
Thanks a million, I'll test this out over the next week! |
Hi, sorry for taking so long to reply - this worked fine. Thanks! |
I'm trying to do the same, I have a file called @echo off
set CMDER_ROOT=C:\Cmder
start %CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.exe /icon "%CMDER_ROOT%\cmder.exe" /title "Homestead VM" /loadcfgfile "%CMDER_ROOT%\config\ConEmu.xml" /cmd cmd /k "%CMDER_ROOT%\vendor\init.bat cd %CD% && %~1" And am running "cmder.bat" "w: && cd \tools\homestead" This causes both a ConEmu prompt and a Cmder prompt to pop up. The commands get executed in the Cmder window but the ConEmu windows stays open with the Is there any way to close the ConEmu window? And another thing I noticed: when creating a new console (via de title bar of the Cmder prompt > New Console...) it starts the same |
I like to make an alias to 'cd' into a deep directory, I created the alias on .minttyrc on my home folder.. but the problem is cmder is not loading that .minttyrc file when startup. How can I make cmder to load that file on (cmder)startup ? |
I still get this weird second ConEmu window... |
I think if you're doing this from within cmder you can use something like this:
Whereas if you need the command to run from outside of cmder, you can then do something like:
Also this can be done if you want to launch Powershell and not cmd (from within cmder):
And for Powershell external from cmder:
|
This worked for me:
|
This batch opens a new cmder console, and optionally runs a command in it. If the command is one of defined shells, then it skips command processor too. @echo off
if "%~1"==":run" goto :run
setlocal
:: Use default path from chocolatey cmder package
if not defined CMDER_ROOT set CMDER_ROOT=%SystemDrive%\tools\Cmder
if not exist "%CMDER_ROOT%\cmder.exe" echo Cmder not found in "%CMDER_ROOT%" >&2 && exit /b 1
if "%~1"=="" (
set CC_RUN=cmd /k "%CMDER_ROOT%\vendor\init.bat"
) else if "%~1"=="sh" (
set CC_RUN=%*
) else if "%~1"=="bash" (
set CC_RUN=%*
) else if "%~1"=="pwsh" (
set CC_RUN=%*
) else if "%~1"=="powershell" (
set CC_RUN=%*
) else (
set CC_RUN=cmd /k %0 :run %*
)
if exist "%CMDER_ROOT%\config\user-ConEmu.xml" (
set CC_CONFIG=%CMDER_ROOT%\config\user-ConEmu.xml
) else (
set CC_CONFIG=%CMDER_ROOT%\config\ConEmu.xml
)
start "Console" "%CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.exe" -Single -NoCloseConfirm -Icon "%CMDER_ROOT%\cmder.exe" -Title "Console" -LoadCfgFile "%CC_CONFIG%" -Run %CC_RUN%
exit /b %errorlevel%
:run
call "%CMDER_ROOT%\vendor\init.bat"
if "%~2"=="" exit /b 0
for /f "tokens=1,* delims= " %%a in ("%*") do set CC_CMD=%%b
echo === %CC_CMD% >&2
call %CC_CMD%
exit /b %errorlevel% |
SOLVED IT:
Hey guys, i don´t get it. |
Why do you have to use Cmder to do this. What is the benefit of doing it with Cmder/ConEmu over just doing:
Do you just want it in a tab? |
this doesnt work, it does not know tail But that brings me to an idea. |
Then either add the folder tail is in to the path or add the fully qualified path to tail in the bat file. To find it inside cmder type |
You could also do the following:
|
Thank you so much for this! If you replace this line
with the following two lines, it will echo the command with a lambda at the beginning, instead of
|
By the way, you can also make Cmder/ConEmu the default terminal on Windows, so that whenever you run a batch file, it will be opened in Cmder automatically. |
@virginviolet Also on Windows 10/11, you can use Cmder in Windows Terminal which has the same set as default terminal feature. |
Hi,
I'd like to be able to write a batch file and run a command through cmder. I've got this so far
However this doesn't seem to run the command. I've been searching around to try and figure out how to do this but I can't find anything. Is it possible? If so I'll submit a pull request and add it to the documentation.
The text was updated successfully, but these errors were encountered: