2

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

1 Answer 1

2

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

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

Your Answer

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

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