I'm programming in Bash (Git BASH) on Windows Server 2012R2.
From within my bash scripts, I would like to make a Screenshot of the mintty window, I'm running in.
According to https://mintty.github.io/ minnty has the ability for "Image screenshot export".
Does anybody know how to use this "Image screenshot export" feature of mintty?
Using printf '\e[12i' seems not to work:
#!/usr/bin/env bash
echo "we start in this directory: $(pwd)";
echo "now printing ...";
printf '\e[12i' >/dev/tty; echo "ret1: $?";
[ -t 2 ] && { printf '\e[12i' >&2; echo "ret2: $?"; }
[ -t 1 ] && { printf '\e[12i'; echo "ret3: $?"; }
echo "printed";
ls -rlt | tail -3;
leads to
$ 99_tmp1.sh
we start in this directory: /d/_bin01
now printing ...
ret1: 0
ret2: 0
ret3: 0
printed
-rwxr-xr-x 1 zzz91289 1049089 48592 Nov 7 10:39 99_cross_const.sh
-rwxr-xr-x 1 zzz91289 1049089 7327 Nov 7 19:54 99_reset_svc.sh
-rwxr-xr-x 1 zzz91289 1049089 419 Nov 7 20:21 99_tmp1.sh
xxxx@Wxxxx MINGW64 /d/_bin01
$
But I can't find the screenshot. Not in current directory. Not in $HOME.
답변1
How to use this "Image screenshot export" feature of mintty
?
Image dump of terminal contents
Mintty can save the visual contents of the terminal screen in an image file mintty.date_time.png. This is supported from the context menu or via user-definable key functions. The current terminal dimensions are used for the image size except in Tek mode, where one of the original Tek sizes is used (depending on whether 12-bit pixel addresses are in effect).
(emphasis mine)
Filename pattern and location are configurable (setting SaveFilename).
Source mintty
To save an image using cygwin mintty
, right click to open the context menu and click Save as Image
It looks like you can define key function to do this. The key function can presumably be executed from a bash
script but I have no experience of doing this.
답변2
The thing missing for me was to have a SaveFilename
configured in the .minttyrc file.
From the console, type nano ~/.minttyrc
to open the configuration file in the nano editor. Add the following line (or change it to suit your needs) and save (references and examples here).
SaveFilename=$USERPROFILE/Pictures/mintty/%Y-%m-%d_%H-%M-%S
When you open a new Git Bash window, it will use the new setting and save screenshots to your specified location/file prefix when you right-click and choose "Save as Image".