想象一下:使用类似xmonad的方式在我的emacs窗口中平铺eshells。这个可行吗?我可以通过M-x eshell打开第一个eshell实例,但是后续调用只会将焦点放在第一个实例上。
你可以这样做:
`C-u M-x eshell`
这将创建*eshell*
、*eshell*<2>
等。我倾向于创建命名的shell:
(defun make-shell (name)
"Create a shell buffer named NAME."
(interactive "sName: ")
(setq name (concat "$" name))
(eshell)
(rename-buffer name))
M-x make-shell name
会创建所需的shell。eshell的文档字符串指出:“非数字前缀参数意味着创建一个新会话。”我一遍又一遍地输入M-- M-x eshell,每次都会打开一个新的eshell缓冲区。
(lexical-let ((count 1))
(defun make-eshell-next-number ()
(interactive)
(eshell)
(rename-buffer (concat "*eshell" (number-to-string count) "*"))
(setq count (1+ count))))
(defun buffer-exists (bufname)
(not (eq nil (get-buffer bufname))))
(defun make-shell (name)
"Create a shell buffer named NAME."
(interactive "sName: ")
(if (buffer-exists "*eshell*")
(setq eshell-buffer-name name)
(message "eshell doesnot exists, use the default name: *eshell*"))
(eshell))
对于使用 ansi-term 的用户来说,调用 GNU Screen 是另一个选项
这是我实现的新 eshell 缓冲区 / 实例。
(defun eshell-new-buffer (args)
"Create a new eshell buffer."
(interactive "P")
(eshell "new")
)
(global-set-key (kbd "C-c e e") 'eshell)
(global-set-key (kbd "C-c e n") 'eshell-new-buffer)