I'm very new to emacs and am currently using it to edit files on mac os x. How do I open instances of the shell from inside emacs so that I can execute the code I'm working on?
I wrote this terminal command to open a terminal in the current working directory:
(defun terminal () (interactive) (shell-command (format "open -b com.apple.terminal \"%s\"" (if (buffer-file-name) (file-name-directory (buffer-file-name)) (expand-file-name default-directory)))))
its not an emacs shell, but it is convenient for me.
This is a really nice overview of various shell options in emacs. Which shell you use depends on what you need. Sane term is a nice basic terminal emulator. You can also look at the various settings I use if you like. I tend to use eshell for most things, but occasionally use sane term for more computation heavy tasks.
And here is another way to call a terminal, if you use iterm (which you should) on OS X.
(defun open-dir-in-iterm () "Open the current directory of the buffer in iTerm." (interactive) (let* ((iterm-app-path "/Applications/iTerm.app") (iterm-brew-path "/opt/homebrew-cask/Caskroom/iterm2/2.1.4/iTerm.app") (iterm-path (if (file-directory-p iterm-app-path) iterm-app-path iterm-brew-path))) (shell-command (concat "open -a " iterm-path " .")))) (global-set-key (kbd "C-x t") 'open-dir-in-iterm)