这是我的设置:
(defvar terminal-process)
(defun terminal ()
"Switch to terminal. Launch if nonexistant."
(interactive)
(if (get-buffer "*terminal*")
(switch-to-buffer "*terminal*")
(term "/bin/bash"))
(setq terminal-process (get-buffer-process "*terminal*")))
(global-set-key "\C-t" 'terminal)
您能否详细说明启动时间?我的是0.3s左右。
dired
UPD 我自定义的一个小片段
我的dired
设置中有这个:
(add-hook
'dired-mode-hook
(lambda()
(define-key dired-mode-map (kbd "`")
(lambda()(interactive)
(let ((current-dir (dired-current-directory)))
(term-send-string
(terminal)
(format "cd %s\n" current-dir)))))))
哪里terminal
是:
(defun terminal ()
"Switch to terminal. Launch if nonexistant."
(interactive)
(if (get-buffer "*terminal*")
(switch-to-buffer "*terminal*")
(term "/bin/bash"))
(setq terminal-process (get-buffer-process "*terminal*")))
这样做的目的是为与 dired 缓冲区相同的目录打开一个终端,重用现有的*terminal*
,或者如果它不存在则创建一个新的。
总结一下您的问题的答案:
是的,这是可能的。它完成了:
(term-send-string
(terminal)
(format "cd %s\n" default-directory))