homeport / termshot Goto Github PK
View Code? Open in Web Editor NEWCreates screenshots based on terminal command output
License: MIT License
Creates screenshots based on terminal command output
License: MIT License
On Linux systems, termshot
fails with an IO error:
╭ Error occurred
│ read /dev/ptmx: input/output error
╵
Based on creack/pty#100, this happens because io.Copy()
is reading until io.EOF
. However, if the child process is already done it can happen on a Linux system that the parent process is still trying to read.
Love this project. Would be great if you could add support for basic unicode emojis 🙏
would be useful to me to be able to specify a series of commands, and see each command/output in sequence in the screenshot
would this be feasible to add? could you direct me to the relevant parts of the code?
Seems like this is an issue with bunt.. I'll report it there too.
panic: strconv.ParseUint: parsing "500": value out of range
goroutine 1 [running]:
github.com/gonvenience/bunt.ParseStream.func3({0xc00020c0d0?, 0x0?})
github.com/gonvenience/[email protected]/parse.go:112 +0x48
github.com/gonvenience/bunt.ParseStream.func4()
github.com/gonvenience/[email protected]/parse.go:142 +0x148
github.com/gonvenience/bunt.ParseStream({0x6ce1a8?, 0xc0000f6bd0?}, {0x0, 0x0, 0xc000224000?})
github.com/gonvenience/[email protected]/parse.go:225 +0x4e2
github.com/homeport/termshot/internal/img.(*Scaffold).AddContent(0xc000687bd0, {0x6ce1a8?, 0xc0000f6bd0?})
github.com/homeport/termshot/internal/img/output.go:116 +0x39
github.com/homeport/termshot/internal/cmd.glob..func1(0x960900?, {0xc0000f6b70?, 0x1, 0x3})
github.com/homeport/termshot/internal/cmd/root.go:115 +0x4d0
github.com/spf13/cobra.(*Command).execute(0x960900, {0xc000010090, 0x3, 0x3})
github.com/spf13/[email protected]/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x960900)
github.com/spf13/[email protected]/command.go:1040 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:968
github.com/homeport/termshot/internal/cmd.Execute()
github.com/homeport/termshot/internal/cmd/root.go:144 +0x67
main.main()
./main.go:26 +0x17
I'm trying to use termshot
to capture Nushell output, and it panics.
❯ ./result/bin/termshot nu
❯ ls
╭────┬────────────────────────┬─────────┬────────┬───────────────╮
│ # │ name │ type │ size │ modified │
├────┼────────────────────────┼─────────┼────────┼───────────────┤
│ 0 │ CONTRIBUTING.md │ file │ 8.4 KB │ 8 hours ago │
│ 1 │ COPYING │ file │ 1.1 KB │ 8 hours ago │
│ 2 │ README.md │ file │ 6.2 KB │ 2 months ago │
│ 3 │ default.nix │ file │ 971 B │ a year ago │
│ 4 │ doc │ dir │ 23 B │ 8 hours ago │
│ 5 │ flake.nix │ file │ 2.3 KB │ 2 months ago │
│ 6 │ lib │ dir │ 34 B │ 8 hours ago │
│ 7 │ maintainers │ dir │ 5 B │ 8 hours ago │
│ 8 │ nixos │ dir │ 13 B │ 8 hours ago │
│ 9 │ pkgs │ dir │ 18 B │ a year ago │
│ 10 │ result │ symlink │ 58 B │ 5 minutes ago │
│ 11 │ update-git-commits.txt │ file │ 740 B │ 2 months ago │
╰────┴────────────────────────┴─────────┴────────┴───────────────╯
❯ exit
panic: reached end of file before reaching end identifier
goroutine 1 [running]:
github.com/gonvenience/bunt.ParseStream.func2(0x7)
github.com/gonvenience/[email protected]/parse.go:100 +0x88
github.com/gonvenience/bunt.ParseStream.func4()
github.com/gonvenience/[email protected]/parse.go:172 +0xb8
github.com/gonvenience/bunt.ParseStream({0x6db758?, 0xc00018eb70?}, {0x0, 0x0, 0xc0001e7000?})
github.com/gonvenience/[email protected]/parse.go:225 +0x4ed
github.com/homeport/termshot/internal/img.(*Scaffold).AddContent(0xc000181bd0, {0x6db758?, 0xc00018eb70?})
github.com/homeport/termshot/internal/img/output.go:116 +0x39
github.com/homeport/termshot/internal/cmd.glob..func1(0x9778e0?, {0xc0000b33d0?, 0x1, 0x1})
github.com/homeport/termshot/internal/cmd/root.go:115 +0x4d0
github.com/spf13/cobra.(*Command).execute(0x9778e0, {0xc000016050, 0x1, 0x1})
github.com/spf13/[email protected]/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x9778e0)
github.com/spf13/[email protected]/command.go:1040 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:968
github.com/homeport/termshot/internal/cmd.Execute()
github.com/homeport/termshot/internal/cmd/root.go:144 +0x67
main.main()
github.com/homeport/termshot/cmd/termshot/main.go:26 +0x17
❯
This is with v0.2.5 of termshot
.
I'm not too sure if this is possible, though given the following sequence of commands, I think it should be possible code-wise?
Naturally, if I attempt to use -
as the command or simply nothing, it just errors, though, given the fact it's still able to take stdin as a command, and correctly produce a screenshot, when provided with any valid executable, seems to point to it just being an error handling thing.
If you can point me to where in the code this kind of thing is handled, I'm more than happy to impl it myself and open a pull request :)
Idea:
This might be a no-op, quickly adding this for now.
When I do a git status
and git highlights in RED new files, that color is not preserved if I do a termshot -i "git status"
Is this possible? I dug through the help and previous issues but couldn't find anything. Curious is this is possible.
The generated output filename is fixed at the moment and the file will be overwritten if it exists already. Add code to make the name configurable via a command line flag.
Acceptance Criteria: Be able to specify a filename using the CLI, for example:
termshot --output termshot.png -- uptime
Would be nice to have a light mode when generating the image.
Use case is that our CLI program has both a dark and light mode, and we would like to preview both using termshot.
Mockup of how I envision it (super simple):
Edit: Sorry, just realized that this is a potential duplicate of #80
A new version of the esimov/stackblur-go
module seems to have changes so that stackblur.Process
does not exist anymore. Check how to update to a new version.
Docker File
FROM ubuntu
RUN wget https://github.com/homeport/termshot/releases/download/v0.2.2/termshot_0.2.2_linux_amd64.tar.gz
RUN tar -xf termshot_0.2.2_linux_amd64.tar.gz
RUN chmod +x termshot
RUN cp termshot /usr/bin COPY run.py run.py
CMD ["python3","run.py"]
run.py -
import os
os.system("termshot -c -- ls")
os.system("ls -lah")
I might be using this wrong somehow, but when I run a program that uses inverse text colors (switches text and background colors) it isn't captured in the screenshot.
Thanks 4 termshot
because till today, I just did enlarge the font a lot and did the best screenshot I could to share it with someone.
Works good when doing basic CLI screenshot:
$ termshot --show-cmd -- ls -1
But adding --edit
command, editor show content, but stay frozen:
$ termshot --edit --show-cmd -- ls -1
I did try changing editor (vis, nano, busybox vi) with same result:
$ EDITOR=nano termshot --edit --show-cmd -- ls -1 ~/.config/mpv
This is the frozen output (ls -1 ~/.config/mpv):
^[[38;2;0;255;0m...^[[0m ^[[38;2;105;105
input.conf^M
mpv.conf^M
scripts^M
shaders^M
~
~
~
~
~
bad option: number
Then I had to open another terminal to unfrozen it (by killing): pkill termshot
I did try with two terminals, with | without multiplexer, but happens the same:
xterm
kitty
st
tmux
I did use:
brew install homeport/tap/termshot
from README.md
Maybe it's the same and will work if I do compilation by myself with last GIT. I'm no programmer and just do AUR compilations, if I get a minimal problem, I'm not able to fix it.
Software versions:
$ termshot -v
termshot version 0.2.7
$ xterm -v
XTerm(390)
$ st -v
st 0.9
$ kitty -v
kitty 0.31.0 created by Kovid Goyal
$ neofetch distro kernel
distro: Arch Linux x86_64
kernel: 6.1.52-1-lts
@HeavyWombat suggested looking at termshot
in homeport/dyff#264, and I tried running it with the commands I used there. The output is gorgeous, but quite large: The MacOS screenshot was a 30k PNG, and the termshot
one was 134k. That's probably just the resolution difference: termshot
gave me a 2051 x 1462 image, while I grabbed a 443 x 308 image with the screenshot. termshot
seems more efficient per pixel, but maybe an option to reduce the resolution would be handy.
if your script prints with emojis they dont render in the screenshot.
Using github.com/fogleman/gg
and Hack font, it is currently not possible draw U+2717 BALLOT X (cross).
Issue description:
I'm using latest termshot to generate an image based on an ls
cmd. I can see that the stdout of my cmd is not fitting into the rounded rectangle but it actually exceeds it(in other words, the list of files and directories is incomplete in the generated image). I unfortunately was not able to understand why, any ideas?
Would be good if you can reproduce this from your side.
Use Go 1.17 embed feature rather than go-bindata
.
Hi, great work,
Have you consider adding an --output
flag so the filename is not defaulting to out.png
Idea: Add a flag to configure text that is later highlighted in the output. It could be encircled with a red oval, or some kind or arrow is used, or simply text color is added. Options could include from highlighting only piece of text or the entire line.
I get the following panic when trying to use termshot -- pfetch
and termshot -- "./simple-go-cli-program"
, the latter just prints plain text, it's a tiny go program I wrote to test.
I think this has to do with color handling in my terminal? Though, I'm not sure why my Go program (only using log.Printf) would have any color escapes in the output.
panic: move cursor value is out of bounds
goroutine 1 [running]:
github.com/gonvenience/bunt.ParseStream.func4()
github.com/gonvenience/[email protected]/parse.go:144 +0x1a8
github.com/gonvenience/bunt.ParseStream({0x102456738?, 0x1400016ac00?}, {0x0, 0x0, 0x1400033f000?})
github.com/gonvenience/[email protected]/parse.go:225 +0x3b0
github.com/homeport/termshot/internal/img.(*Scaffold).AddContent(0x14000123bb8, {0x102456738?, 0x1400016ac00?})
github.com/homeport/termshot/internal/img/output.go:118 +0x3c
github.com/homeport/termshot/internal/cmd.glob..func1(0x1026eca80?, {0x1400016aba0?, 0x1, 0x3})
github.com/homeport/termshot/internal/cmd/root.go:120 +0x39c
github.com/spf13/cobra.(*Command).execute(0x1026eca80, {0x14000132050, 0x3, 0x3})
github.com/spf13/[email protected]/command.go:940 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x1026eca80)
github.com/spf13/[email protected]/command.go:1068 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:992
github.com/homeport/termshot/internal/cmd.Execute()
github.com/homeport/termshot/internal/cmd/root.go:162 +0x64
main.main()
./main.go:26 +0x1c
Using the following answer from StackoverFlow with pfetch
does indeed work as expected, though without and color or formatting.
If there's any other info I can help provide, please let me know.
Is it possible to save the contents of your termshot to clipboard instead of file?
I'm using MacOS Ventura which has pbcopy/pbpaste
. Would it work if you can pass the output to STOUT?
Command would look something like
termshot --<COMMAND FOR CLIPBOARD> --- ls .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.