0

I am learning to develop Rails on Windows. As the Rails implementation is far from perfect on Windows, I use a virtual machine to launch the various Rails tools and servers, using Vagrant.

Each time I start my environment, I do the following :

  • open 4 ConEmu Powershell tabs in my folder
  • in the first tab, subl ., then vagrant up and wait for it to finish
  • vagrant ssh (it uses the ssh client from my "Git for Windows" installation, I guess it's OpenSSH) in the first 3 tabs then cd /vagrant in each
  • in the first tab, rake db:migrate then rake test:prepare
  • in the first tab, rails s ; in the second tab, guard -pc
  • the fourth tab is just left alone, it's used for git commands

Can you envision a script, or a series of scripts, that can launch all these commands ? I can think of a convoluted way of how to open the 4 tabs and launch the vagrant ssh (I didn't check if it worked yet), but I don't even know if it's possible to handle ssh sessions this way.

thomasb
  • 5,816
  • 10
  • 57
  • 92
  • Don't know about "vagrant ssh", but I believe it can accept commands/script files. Also, you've not described what do you do in fourth tab. – Maximus Aug 20 '13 at 13:00
  • You're right, I have added it. The first tab is the web server, the second the unit tests, in the the third I type my rails commands, and in the fourth, my git commands. – thomasb Aug 20 '13 at 17:51
  • Btw, you have not mention in your Q "third tab". – Maximus Aug 25 '13 at 01:30
  • Yes I have (third bullet point): I launch "vagrant ssh" in it, then "cd /vagrant", and then it's used for Rails commands. – thomasb Aug 26 '13 at 16:51

1 Answers1

1

Here is your starting point. Create powershell script (RunVG.ps1 for example)

Start-Process "vagrant" "up" -Wait -NoNewWindow
Start-Process "vagrant" "ssh", "-new_console:s1THb" -Wait
Start-Process "vagrant" "ssh", "-new_console:s1TVb" -Wait
Start-Process "powershell" "-new_console:s2TVb"
& "vagrant" "ssh"

and run ConEmu with following command line (change path to RunVG.ps1 accordingly)

ConEmu /cmd powershell -NoExit -Command "C:\Vagrant\RunVG.ps1"

After finishing script execution you will get connected ssh in first three tab and powershell in fourth tab. Actually, you'll get 2x2 splits, not tabs. If you don't need splits - use plain "-new_console".

Now, you need only pass additional arguments into your ssh instances for running commands in your tabs. Consult with ssh manual or competent users.

UPD1 Pasting into console example (this must be called from ConEmu's console)

conemuc /GUIMACRO Paste(2,"echo abc\necho def\n")
Maximus
  • 10,751
  • 8
  • 47
  • 65
  • Awesome thanks! I'll be sure to try it. Doesn't ConEmu supports "typing in the console", like "paste" seems to do ? That would be awesome for things like SSH commands. – thomasb Aug 26 '13 at 16:54