title: How do I define an Emacs Lisp function to spawn a shell buffer with a particular command executed in the shell?
body: <p>I am doing Rails development and find that I need to spawn a <em>shell</em>, rename the buffer (e.g. webrick), then kick off the command (rails s) and then do the whole thing over again if I want a rails console or rails dbconsole, rspec, spork, etc. every time I start up emacs.</p>
  
  <p>I am hoping for something like this:</p>
  
  <pre><code>(defun spawn-shell ()
     "Invoke shell test"
      (with-temp-buffer
        (shell (current-buffer))
        (process-send-string nil "echo 'test1'")
        (process-send-string nil "echo 'test2'")))
  </code></pre>
  
  <p>I don't want the shell to go away when it exits because the output in the shell buffer is important and some times I need to kill it and restart it but I don't want to lose that history.<br>
  Essentially, I want to take the manual process and make it invokable.</p>
  
  <p>Any help is much appreciated</p>
  
  <p>Tom</p>