Page 1 of 2

Configurable command shell

Posted: 25 Jun 2012, 15:38
by dabide
Salamander uses CMD when running commands with Ctrl-Enter, or when launching a command shell. It would be very nice if this could be made configurable, so that we could use for instance Console 2 or ConEmu.

Re: Configurable command shell

Posted: 26 Jun 2012, 14:40
by Jan Rysavy
Set the ComSpec environment variable: http://en.wikipedia.org/wiki/ComSpec

Re: Configurable command shell

Posted: 26 Jun 2012, 15:44
by Ether
Setting COMSPEC environment variable can lead to various problems with your system, as some applications (and possibly even parts of Windows) are depending on COMSPEC to contain the path to the cmd.exe shell or at least a compatible one (regarding accepted switches). I recommend reading the following discussions:

A discussion about a problem with Komodo software, topics related to COMSPEC here, on Salamander Forums, especially this one that uses AutoHotKey to launch Console2 from Salamander.

Re: Configurable command shell

Posted: 27 Oct 2015, 10:35
by treb
So latest answer is do not use COMSPEC- but what else?

Re: Configurable command shell

Posted: 28 Oct 2015, 18:47
by SvA
Well, I think you are drawing the wrong conclusion. You should use COMSPEC to point to any command shell you like. That shell should be compatible to cmd.exe, though.

But what about setting up cmd.exe to automatically lauch the shell wrapper of your liking, if that is not compatible? There is a registry entry you can set to a command or script that is launched at start. Also there is %CMDCMDLINE% so you can get at the parameters passed to cmd.exe.

I did not delve into what problems people had with setting COMSPEC, but I really don't see what should break when used with a compatible replacement. Any shell that is not compatible is obviously ment to not be a replacement, such as for example powershell.

Re: Configurable command shell

Posted: 11 Nov 2015, 13:40
by Ether
IIRC ConEmu has an option to automatically steal any console windows and put them inside ConEmu.

Re: Configurable command shell

Posted: 03 Dec 2015, 15:12
by treb
Hello,
I also would like to have such setting inside Altap Salamander and make settings easier than any other option pointed above.
I really think that addition is easier to provide compared to the benefit we will have...



Regards!

Re: Configurable command shell

Posted: 03 Dec 2015, 22:39
by Jan Rysavy
We don't use Console 2 nor ConEmu, so I will ask basic questions.
Do you expect we will call "ConEmu.exe /cmd cmd /k ..." instead of current "cmd /k ..."?
ConEmu.exe would be path from AS configuration, default clear/unused.

Re: Configurable command shell

Posted: 04 Dec 2015, 07:57
by treb
Hello,
First thanks for answering.
Second - I really expect that idea is to be able to call any terminal with passing just file and path like :
"ConEmu.exe" /cmd \"%1\" %*"

I do't understand your last question/sentence can you clarify?

Re: Configurable command shell

Posted: 04 Dec 2015, 09:43
by Jan Rysavy
What is Salamander doing now when invoking CMD:
1. get environment variable COMSPEC
2. attach /C or /K according to http://www.altap.cz/salamander/help/sal ... k_cmdline/ (Close shell window after command execution)
3. attach command line content
4. execute it through CreateProcess API, for example: "C:\Windows\system32\cmd.exe /K "dir""

I assume there should be some new option in AS configuration to start this command using another application. Will be plain text edit line enough? Just one string we will insert to CreateProcess() command?

Instead of "C:\Windows\system32\cmd.exe /K "dir""
we will execute "XYZ C:\Windows\system32\cmd.exe /K "dir""
where XYZ will be such string from configuration? You will be able to put "ConEmu.exe /cmd" there.

Is it all you need? Just one global variable in AS configuration with string XYZ?

Re: Configurable command shell

Posted: 04 Dec 2015, 10:10
by treb
Hello Jan,
thanks for answering!
Yes even such an option will be very useful and option for better configuration.

I was hoping also for a more separated approach:
1. Field (string ) for Environment variable - "COMSPEC" by default
2. Field for options 1 - /C by default
3. Field for options 2 - /K by default
4. Field for option 3 - %DIR - placeholder for starting dir



But of course this is just an idea

Regards

Re: Configurable command shell

Posted: 04 Dec 2015, 10:24
by Jan Rysavy
It looks like feature for very small part of Altap Salamander users so we would like to keep it as small as possible (space in configuration dialog box, space in Windows Registry, description in AS help, size in AS code base).

In this light, would be my "one optional XYZ string" solution enough for your needs? If no, could you describe such usage scenario?

Re: Configurable command shell

Posted: 04 Dec 2015, 17:01
by SvA
What about using user menu entries (or using the same interface to configure entries)? Thus you have a flexible framework integrated already. You just need an interface to assign these entries to the different places where the shell is called (Command Line toolbar with or without a command; from a file panel, from the user menu with and without the close option, and maybe more. Different approaches to this could be taken.
Jan Rysavy wrote:we will execute "XYZ C:\Windows\system32\cmd.exe /K "dir""
What if i can't cope with the C:\Windows\system32\cmd.exe part? What if my shell needs something different from /C and /K? What if the shell needs some other way to set the working directory?

I believe, two text boxes with variable substitution is the bare minimum to support this in a useful way other than referring people to COMSPEC.

Take for example PowerShell, an command shell that is completely incompatible to cmd when it comes to launchig it. But Powershell has been requested in the past as a replacement for command line consoles from Salamander. What does it take to configure it in AS?

Re: Configurable command shell

Posted: 04 Dec 2015, 17:15
by Jan Rysavy
Unfortunately it doesn't look like a small patch.

PowerShell thread: http://forum.altap.cz/viewtopic.php?f=3&t=1957

Re: Configurable command shell

Posted: 04 Dec 2015, 17:30
by Jan Rysavy
Note: Salamander is calling %COMSPEC% from:
-Command Line (with /C or /K parameter, command from edit line)
-Command Shell command (Num /)
-User Menu (with /C or /K parameter, command from User Menu item)
-Renamer dialog box, Filter List Through Shell Command (with /C parameter, command from edit line)