Agreeable-Solid7212 · 2022-04-17 17:33
I'm trying to make some of my own elisp functions to mimic the vscode terminal functionality (a window with a smaller vterm buffer). Here is what I have now:
```
(defun open-term ()
(interactive)
(split-window-vertically)
(other-window 1)
(vterm))
```
It works, but the window is too big. How can I reduce the size of the window?
h-m-b-tu · 2022-04-17 17:48
There is `window-resize` which is called by `shrink-window`.
TheFrenchPoulp · 2022-04-17 18:06
Have you considered https://github.com/karthink/popper ?
htonl · 2022-04-17 19:48
You should be able to do something like this:
(add-to-list 'display-buffer-alist
'("\*vterm\*"
(display-buffer-in-side-window)
(window-height . 0.25)
(side . bottom)
(slot . 0)))
akirakom · 2022-04-17 20:13
Popper can handle this. You can use the following snippet:
(vterm--internal popper-display-function)
and add `vterm-mode` to `popper-reference-buffers`.
guitmz · 2022-04-17 20:40
vterm-toggle package maybe? Seems to work for me just fine
ckoneru · 2022-04-17 23:34
[https://github.com/kyagi/shell-pop-el](https://github.com/kyagi/shell-pop-el)
;; Shell Pop
(use-package shell-pop
:bind (("C-`" . (lambda ()
(interactive)
(if (fboundp 'vterm-posframe-toggle)
(vterm-posframe-toggle)
(shell-pop nil))))
([f9] . shell-pop))
:init
(setq shell-pop-window-size 30
shell-pop-shell-type
(cond ((fboundp 'vterm) '("vterm" "*vterm*" #'vterm))
(sys/win32p '("eshell" "*eshell*" #'eshell))
(t '("terminal" "*terminal*"
(lambda () (term shell-pop-term-shell)))))))
yep808 · 2022-04-18 01:06
You can use the vterm-toggle package
mistarchou · 2022-04-18 15:41
based on u/htonl's answer
(use-package vterm-toggle
:bind
(("C-`" . vterm-toggle)
:map vterm-mode-map
("<C-return>" . vterm-toggle-insert-cd))
:config
(add-to-list 'display-buffer-alist
'("\*vterm\*"
(display-buffer-in-side-window)
(window-height . 0.3)
(side . bottom)
(slot . 0))))
my original solution:
```elisp
(defun vterm-split-window-below ()
(interactive)
(vterm)
(split-window-below -12)
(previous-buffer)
(other-window 1))
(defun vterm-toggle ()
"Toggle vterm open and hide with Control + `"
(interactive)
(if (eq major-mode 'vterm-mode)
(delete-window)
(vterm-split-window-below)))
```
cabbagegandalf · 2022-05-20 14:27
Not op but just stumbled on this and it's great!