1

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

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 '20 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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