App-nup

 view release on metacpan or  search on metacpan

images/capture.sh  view on Meta::CPAN

)

. getoptlong.sh OPTS "$@" || exit 1

if [[ -n "$help" ]] || [[ $# -eq 0 ]]; then
    echo "Usage: $0 [-o output.png] [-c cols] [-r rows] command..."
    echo "Example: $0 -o nup.png 'nup man nup'"
    exit 0
fi

OUTPUT="$output"
COMMAND="$*"

# Create iTerm window, run command, and get window ID
WIN_ID=$(osascript <<EOF
tell application "iTerm"
    set newWin to (create window with default profile)
    delay 0.3

    tell current session of newWin
        -- Set terminal size

images/capture.sh  view on Meta::CPAN

EOF
    sleep 1
fi

# Capture screenshot
if [[ $shadow ]]; then
    osascript <<EOF
tell application "iTerm"
    set newWin to (window id $WIN_ID)
    delay 0.3
    do shell script "screencapture -l " & (id of newWin) & " $OUTPUT"
    close newWin
end tell
EOF
else
    osascript <<EOF
tell application "iTerm"
    set newWin to (window id $WIN_ID)
    delay 0.3

    set winBounds to bounds of newWin
    set x1 to item 1 of winBounds
    set y1 to item 2 of winBounds
    set x2 to item 3 of winBounds
    set y2 to item 4 of winBounds
    set w to x2 - x1
    set h to y2 - y1

    do shell script "screencapture -R" & x1 & "," & y1 & "," & w & "," & h & " $OUTPUT"
    close newWin
end tell
EOF
fi

if [ -f "$OUTPUT" ]; then
    echo "Screenshot saved: $OUTPUT"
    ls -la "$OUTPUT"
else
    echo "Failed to create screenshot" >&2
    exit 1
fi



( run in 1.730 second using v1.01-cache-2.11-cpan-13bb782fe5a )