theurgy/userland/terminal.el

64 lines
1.9 KiB
EmacsLisp

;;; terminal.el --- Userland terminal with vterm -*- lexical-binding: t -*-
;; This file is not part of GNU Emacs
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; commentary
;;; Code:
(when (not (equal system-type 'windows-nt))
(use-package vterm
:ensure t))
(defun theurgy-shell ()
(interactive)
(if (fboundp 'vterm)
'vterm
'shell))
(defun theurgy-bottom-shell ()
"Put a shell in the bottom of the frame."
(interactive)
(let ((win (car (window-at-side-list nil 'bottom))))
(if (and win (equal 'bottom (window-parameter win 'window-side)))
(delete-window win)
(funcall (theurgy-shell)))))
(defun theurgy-main-shell ()
"Put a shell in a main window."
(interactive)
(if (get-buffer "*Shell Session*")
(switch-to-buffer "*Shell Session*")
(funcall (theurgy-shell) "*Shell Session*")))
(define-key global-map (kbd "C-<return>") 'theurgy-main-shell)
(global-set-key (kbd "M-RET") 'theurgy-bottom-shell)
(define-key vterm-mode-map (kbd "M-RET") 'theurgy-bottom-shell)
(add-to-list 'display-buffer-alist
'("\\*vterm\\*\\|\\*shell\\*"
(display-buffer-in-side-window)
(side . bottom)
(slot . 0)
(window-height . 0.2)))
(provide 'terminal)
;;; terminal.el ends here