Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3873140
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:00:08+00:00 2026-05-19T22:00:08+00:00

I want to have a make-shells command in emacs that will open a number

  • 0

I want to have a make-shells command in emacs that will open a number of emacs-shell buffers, each with its own working directory. The idea is that for each project I’m working on, I have a shell that starts out in that project’s directory, so I can easily switch between them.

Currently I have this code:

(defun shell-dir (name dir)
  (interactive "sShell name: \nDDirectory: ")
  (shell name)
  (switch-to-buffer name)
  (comint-send-string (current-buffer) (concat "cd " dir "\r"))
  (sleep-for 0 10)
  (dirs))

(defun make-shells ()
  (interactive)
  (shell-dir "project1" "~/proj/project1")
  (shell-dir "project2" "~/proj/project2")
  (shell-dir "project3" "~/proj/project3")
  (delete-window))

This is pretty ugly, though, and half the time (dirs) doesn’t pick up the correct path, so tab completion breaks until I re-run it manually. Is there a built-in way to set the current working directory of the emacs shell? Or would something like CEDET (plus less reliance on the shell vs. emacs modes) be a much better solution to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:00:09+00:00Added an answer on May 19, 2026 at 10:00 pm

    I experienced similar problems with the current directory tracking provided by Emacs, so I wrote one which solves the problem once and forever.

    Check it out here.

    The short version of what it does is that you modify your shell prompt to include a full path to the current directory (only when running inside Emacs), and the Emacs shell buffer will use that.

    This means you never have to do M-x dirs again.

    There’s also the package dirtrack (shipped with Emacs) which does the same thing.

    I like my version better because it removes the path from the prompt. I don’t want to see the entire path in my prompt as my current directory is often very long.

    Once you use one of the above two solutions, you can simplify your shell-dir routine to be:

    (defun shell-dir (name dir)
      (interactive "sShell name: \nDDirectory: ")
      (let ((default-directory dir))
        (shell name)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little program that I want to make open automatically when my
I want to make sure that a set of functions have the same signature
I have a set of divs that I want to make collapsible/expandable using jQuery's
I have a directory on a linux box that I want to make publicly
I have a virtual path (example: ~/Images/Banner.jpg) and I want to make that an
I have an object of the type System.Drawing.Image and want to make every pixel
I have a C# .NET page where I want to make rows collapse when
I want to make a development server for Ruby. (I have done this for
I have an array, and I want to make a hash so I can
I have the following markup, and I want to make the All radio button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.