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
  • Just an idea, and a bit hacky, but does the shell directory come from the currently open buffer's directory? If so, you could open a temp file in each directory, and start the shell after opening the file. Commented Feb 18, 2010 at 12:40

2 Answers 2

4

The following works for me

(let ((default-directory "/path/to/whereever/"))
  (shell "*shell1*"))
Sign up to request clarification or add additional context in comments.

3 Comments

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
Try adding a trailing slash, i.e. "/path/to/wherever/".
Works, even with "\\" for backslash on windows. Thank you!
0
(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.

3 Comments

That would be awesome. Have no time to playu with this now, maybe later tonight.
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!
Yeah, Ivan answer is a straightforward solution :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.