I want to open an instance of a terminal emulator (in my case term) and go to a specific directory, all with a single Elisp function. My idea was to send a specific string programmatically to the shell, telling it to change to a specific directory. But I don't know how I should do it, and I've not been able to find an alternative (like sending the cd command as the shell is opened).

How can I achieve this?


1 Answer 1


One method would be to let-bind the default-directory when opening term:

(let ((default-directory "/path/to/desired/directory/"))
  (term "/bin/sh"))
  • An elegant and functional solution! Thank you!
    – Andrea
    Commented Oct 30, 2020 at 23:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.