tags:

views:

110

answers:

2

I would like to start a few shells, and set their directories from my .emacs. Opening them is easy:

;; run a few shells.
(shell "*shell5*")
(shell "*shell6*")
(shell "*shell7*")

But I would like to specify their directory, too.

+1  A: 
(shell "*shell5*")
(with-current-buffer "*shell5*"
(goto-char (point-max))
(insert "cd dir")) ;;for example
(comint-send-input nil t) ;; enter

For now I have this, its need some improvement I think. When I use in my emacs its causes an error, but does what you want. I will try to figure why.

coelhudo
That would be awesome. Have no time to playu with this now, maybe later tonight.
sandos
I think my accepted solution is probably better, but this idea is still interesting if I would like to do anything else in the shell!
sandos
Yeah, Ivan answer is a straightforward solution :)
coelhudo
+4  A: 

The following works for me

(let ((default-directory "/path/to/whereever/"))
  (shell "*shell1*"))
Ivan Andrus
Did not work for me, for example if i use /usr/src, the shell start on /usr only, the same happens with /home/guest, starting on /home
coelhudo
Try adding a trailing slash, i.e. "/path/to/wherever/".
jlf
Works, even with "\\" for backslash on windows. Thank you!
sandos
Yeah, it works, my mistake :)
coelhudo