Although I’m using emacs dired as my default file manager, I don’t like any of the terminal emulators in Emacs at all. I usually use a separate application for working with shell command (iTerm on Mac). The problem is that when I’m browsing my files in Emacs and I want to open terminal for doing shell commands in the current directory, I have to copy the path of the current directory, open terminal and type cd to that folder.
I’ve written a small function to help me quickly open a new terminal window at the current directory that I’m browsing in Emacs (MacOS only).
;; default terminal application path
(defvar tmtxt/macos-default-terminal-app-path
"/Applications/Terminal.app" "The default path to terminal application in MacOS")
;;; function to open new terminal window at current directory
(defun tmtxt/open-current-dir-in-terminal ()
"Open current directory in dired mode in terminal application.
For MacOS only"
(interactive)
(shell-command (concat "open -a "
(shell-quote-argument tmtxt/macos-default-terminal-app-path)
" "
(shell-quote-argument (file-truename default-directory)))))