Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noborus/guesswidth
Guess the width (fwf) output without delimiters in commands that output to the terminal.
https://github.com/noborus/guesswidth
fixed-width fwf
Last synced: about 1 month ago
JSON representation
Guess the width (fwf) output without delimiters in commands that output to the terminal.
- Host: GitHub
- URL: https://github.com/noborus/guesswidth
- Owner: noborus
- License: mit
- Created: 2023-03-13T00:51:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-06T04:52:31.000Z (12 months ago)
- Last Synced: 2024-02-01T11:06:47.674Z (5 months ago)
- Topics: fixed-width, fwf
- Language: Go
- Homepage:
- Size: 170 KB
- Stars: 20
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- cli-apps - guesswidth - Guess the width output without delimiters in commands that output to the terminal. (<a name="utility"></a>Utilities)
- awesome-cli-apps - guesswidth - Guess the width output without delimiters in commands that output to the terminal. (<a name="utility"></a>Utilities)
README
# guesswidth
[![Go Reference](https://pkg.go.dev/badge/github.com/noborus/guesswidth.svg)](https://pkg.go.dev/github.com/noborus/guesswidth) [![Go](https://github.com/noborus/guesswidth/actions/workflows/build.yml/badge.svg)](https://github.com/noborus/guesswidth/actions/workflows/build.yml)
## Overview
guesswidth guesses the column position for fixed-width formats(fwf).
The output of the `ps` command has no delimiters, making the values difficult to machine-readable.
guesswidth guesses smarter than just space delimiters.guesswidth is guessed based on the position of characters in the **header**.
So having a header will give you better results.## Install command
There is also a guesswidth command.
```console
go install github.com/noborus/guesswidth/cmd/guesswidth@latest
```Guess the width output with no delimiters in the command.
```console
$ ps
PID TTY TIME CMD
302965 pts/3 00:00:12 zsh
733211 pts/3 00:00:00 ps
733212 pts/3 00:00:00 tee
733213 pts/3 00:00:00 guesswidth
```Split the output like this:
```console
$ ps | guesswidth
PID| TTY | TIME|CMD
302965| pts/3 | 00:00:08|zsh
539529| pts/3 | 00:00:00|ps
539530| pts/3 | 00:00:00|guesswidth
```It can be converted to `csv`.
```console
$ ps | guesswidth csv
PID,TTY,TIME,CMD
302965,pts/3,00:00:12,zsh
733211,pts/3,00:00:00,ps
733212,pts/3,00:00:00,tee
733213,pts/3,00:00:00,guesswidth
```##
## Examples
guesswidth inserts a delimiter (| by default)
(Colors are changed here for clarity).Even if there are spaces in the header or body, they will be separated correctly.
### ps
![ps](./docs/ps.png)
### docker ps
![docker-ps](./docs/docker-ps.png)
### docker node
![docker node ls](./docs/docker-node.png)