Skip to content
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

Using ConEmu instead of default cmd #134

Closed
ibnumalik opened this issue Nov 15, 2016 · 9 comments
Closed

Using ConEmu instead of default cmd #134

ibnumalik opened this issue Nov 15, 2016 · 9 comments

Comments

@ibnumalik
Copy link

requesting support

Hi,
I would like to run custom command using ConEmu instead of the default cmd.

I have check the .ini file and read the manual that in order to change it we use the setting like this

[external]
terminal = "${env:PROGRAMFILES}\ConEmu\ConEmu64.exe" /cmd

The path is correct, but keypirinha still use the default cmd terminal from windows. I am running the keypirinha portable version.

Any help or pointer would be great. thanks for the app!

@ueffel
Copy link

ueffel commented Nov 15, 2016

Looking here its seems that the /cmd or -cmd command line switch has renamed to /run or -run
so i would try

[external]
terminal = "${env:PROGRAMFILES}\ConEmu\ConEmu64.exe" /run

in the KP config.

@ibnumalik
Copy link
Author

nope still not working. thanks for pointing me to the manual @ueffel 🙂

@ueffel
Copy link

ueffel commented Nov 15, 2016

I don't have ConEmu64, i prefer ConsoleZ. Here is what i noticed for ConsoleZ:
If I start a bash shell within consolez it works with terminal = "e:\tools\ConsoleZ\Console.exe" -t "Bash" -r
(-t Selects the Shell, -r sends the following command to the shell)

If I try the same with cmd starting in consolez it doesn't work (terminal = "e:\tools\ConsoleZ\Console.exe" -t "Cmd" -r

As far as I can determine cmd needs either /k or /c as parameter before the command to start. (/k to keep cmd open after command, /c to close cmd after executing the command)

So terminal = "e:\tools\ConsoleZ\Console.exe" -t "Cmd" -r /k would be the right thing but that doesn't work because everything after -r should be a single parameter but it isn't.
To illustrate what I mean: Lets say a want to launch my_script.bat from keypirinha and have terminal = "e:\tools\ConsoleZ\Console.exe" -t "Cmd" -r /k configured.
"e:\tools\ConsoleZ\Console.exe" -t "Cmd" -r /k my_script.bat is executed.
ConsoleZ launches and emulated cmd /k. The my_script.bat part is interpreted by ConsoleZ and by interpreted I mean ignored.

there should be a way to insert a placeholder with the command from Keypirinha, so that I can configure something like this: "e:\tools\ConsoleZ\Console.exe" -t "Cmd" -r "/k $KP_COMMAND". The /k quoted together with the actual command to launch.
That way "e:\tools\ConsoleZ\Console.exe" -t "Cmd" -r "/k my_script.bat" is launched and everything would work as intended.

@polyvertex
Copy link
Member

polyvertex commented Nov 16, 2016

@ibnumalik could you make a dump of the item you try to execute (including its arguments, if any)?
To do that, search for the item, like if you would launch it, and press Alt+Enter. KP's console window will open and you can copy and paste the whole Item properties block here.

@ibnumalik
Copy link
Author

@ueffel thanks for your long explanation. I am still learning cli myself.

@polyvertex hi, here is rhe properties requested.

17:40:52.014 Item properties:
  label:           ibnumalik
  args:            
  short_desc:      Custom command: cmd /K ssh ibnumalik
  target:          ibnumalik
  category:        #1001 (1001)
  args_hint:       forbidden
  hit_hint:        noargs
  plugin:          Apps.Apps
  item_id:         13155397931584381546
  loop_on_suggest: false
  data_bag:

@polyvertex
Copy link
Member

polyvertex commented Nov 18, 2016

@ibnumalik Your whole config is OK. At least this is how it is supposed to be ideally, but thanks to your question, I realized the Apps package won't detect the executable to be a console executable unless its full path is specified. This will be corrected in the next release.

Meanwhile, as a workaround in your Apps.ini file:

[cmd/Whatever]
cmd = "${env:COMSPEC}" /K ssh ibnumalik

Or:

[cmd/Whatever]
cmd = "${env:WINDIR}\system32\cmd.exe" /K ssh ibnumalik

Or:

[cmd/Whatever]
cmd = "C:\Windows\system32\cmd.exe" /K ssh ibnumalik

Again, in the next release, your initial config (i.e. cmd /K ssh ibnumalik) will work just fine. Sorry for the inconvenience.

EDIT Note that, in case you're not aware of it, the cmd /K part is unnecessary unless you want to take advantage of the /K flag.

@ibnumalik
Copy link
Author

@polyvertex thanks for solving this problem. 😄

@polyvertex
Copy link
Member

@ibnumalik The following should now work as of v2.9.8:

[cmd/Whatever]
cmd = ssh ibnumalik

@polyvertex
Copy link
Member

polyvertex commented Jan 14, 2017

there should be a way to insert a placeholder with the command from Keypirinha, ...

@ueffel I just realized I have skipped this part of your comment sorry. Anyway, it doesn't seems to be the right thing to do in Keypirinha because Console2 and ConsoleZ do it wrong IMO (i.e. what about script's arguments that include space chars then?). As an example of a better alternative, many GNU tools use the -- arg for this specific case, which means "stop to parse arguments and pass the remaining ones as-is to the process to launch". It would be more standard and predictive for the user.

I didn't know about ConsoleZ but this issue is the main reason why I moved from Console2 to ConEmu as it was just a PITA to launch scripts with it. Since you started this, I suggest you open an issue on ConsoleZ project and see what's author's answer. They might not want to change it because it's inherited behavior, but we'll see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants