- I wrote a little recreational elisp for resizing windows from within eshell.
- I'm not totally happy with the result, but I figured I'd post what I had and see if anyone had any ideas on how to improve this.
(defun eshell/resize (&rest args)
"Resize windows from eshell using `window-resize'."
(eshell-eval-using-options
"resize" args
`((?z "horizontal" nil resize-horizontal "resize a window's width instead of the height")
(?p "pixel" nil pixelwise "resize by pixel instead of charcter")
(?w "window" t window "resize a specific window instead of the current window")
(?i "ignore" nil ignore "ignore window resizing constraint variables")
(?n "negative" nil negative "use a negative delta (to shrink the window)")
(?h "help" nil nil "show help message")
:usage "[OPTION]... <DELTA>"
:post-usage "Resize window.\n\n")
(unless args
(setq args (list "0")))
(let* ((x (if negative -1 1))
(delta (* x (string-to-number (car args)))))
(message "window %s" window)
(window-resize window delta resize-horizontal ignore pixelwise))))
Usage from within eshell:
# Resize current window's height by +10 lines.
resize 10
# Resize current window's height by -10 lines.
# (-n stands for "negative")
resize -n 10
# Resize current window's width by 10 columns.
# (I put horizontal on -z, because I wanted to leave -h for help.)
resize -z 10
# Resize current window's width by -10 columns.
resize -z -n 10
- The -p options works as you would expect.
- The -w option does not work. I was hoping I could pass it a window struct, but it seems to get stringified.
- I really wish I didn't need -n, but eshell-eval-using-options doesn't let me pass negative numbers. It tries to interpret anything with a leading "-" as an option.