6 ms·
It's good to know the underlying low-level terminal commands that make this work like this article explains. But I guess most people will use a terminal abstrac
by zorr 5y ago
It's good to know the underlying low-level terminal commands that make this work like this article explains. But I guess most people will use a terminal abstraction library that has a higher level API to move the cursor, clean the screen etc.
Terminals are complex beasts and they can do powerful things. If you're interested in this, I can recommend reading the source code for Tmux, JLine3 and some other libraries shell formatting or TUI libraries.
- pantulis 5y agotqdm in Python was also very nice and easy to use.
- franga2000 5y ago+1 for tqdm - not only does it take less than one line to "automatically" turn any loop into a progress bar, it also supports native progress bars in Jupyter Notebooks and even a basic GUI one
- formerly_proven 5y agoTerminal abstraction libraries feel like a relict of the past to me, because there used to be a lot of diversity in command sets and capabilities. Nowadays you can pretty much just assume that most commands work everywhere, so there is a lot less reason to drag around ncurses and friends if you want to make a progress bar that doesn't break your output or have some colored text.
- zorr 5y agoNcurses and friends could be overkill but there is still value in small wrapper libraries that provide a higher level API on top of escape codes. `setCursor(lines, 0)` is more readable than `write(f"\033[{lines};0f")`
- deleted 5y ago[deleted]
- eptcyka 5y agoOh, but you just can't. MacOS's zsh can't deal with my tmux shell when I ssh in. There's all kinds of great features that allow for basically using pixel buffers in a shell if you stray away from the default terminal implementations. Getting colors to work properly is also still a pain.
- gnachman 5y agoThere is still a ton of diversity (underline color, curly underlines, synchronization, and image support for example), but it's nearly impossible to figure out what features are available in a given terminal. I just finished adding vt400 support to iTerm2 this week but I doubt any of it will be used because it's not widely available enough for people to bother.
- WalterGR 5y ago> some other libraries shell formatting or TUI libraries. Any that you’d recommend?
- abdusco 5y agoRich (for formatting) and textual (for TUI) from Will McGugan are great libraries: https://github.com/willmcgugan/rich https://github.com/willmcgugan/rich https://github.com/willmcgugan/textual https://github.com/willmcgugan/textual
- zorr 5y agoI only have some experience with JLine (Java) and Termion (Rust). Heard great things about Textual (Python). There are also smaller libraries focusing on just one aspect like coloring. For example the Colorize Ruby gem.
- sirwitti 5y agoI recently started using python click [1], which is awesome after wrapping my head around some things. Click also provides a useful abstraction for creating progress bars. [1] https://palletsprojects.com/p/click/ https://palletsprojects.com/p/click/
- eliaspro 5y agoBubbletea [1] for Go is quite polished [1] https://github.com/charmbracelet/bubbletea https://github.com/charmbracelet/bubbletea
- flatiron 5y agojust don't read gnu screen!