Comments (7)
Well, boxes has -a
(docs) which should be very similar to Figlet's -lrcx.
You can even center Figlet text, e.g. figlet foo | boxes -a hc -s 50
.
Terminal width is normally something that boxes is agnostic of, because boxes will always try to match the input text. Additional padding can be specified with -p
.
Let me know if maybe that already solves your case!
from boxes.
I just found that on my terminal (Debian / bash), I can
figlet "Hello World !" | boxes -d peek -a hc -s $COLUMNS
To get a box which spans exactly the terminal width. Don't know who keeps the $COLUMNS
up-to-date, but it works out of the box.
from boxes.
The -p and -a flags let me shift the text around inside an oversized box, but I want to realign the box itself to be centered in the terminal, but still fitted to the width of the text. $COLUMNS gets us a bit of the way there, but currently we only have the option to have our box take up the full width, can't center or right justify a smaller box within the width of $COLUMNS.
from boxes.
Ah, I think I get your point now. Thanks for clarifying.
Try this.
Centered box with figlet text:
figlet centered | boxes -d unicornthink | boxes -s $COLUMNS -c x -a hc -i none | cut -c 2-
Right-aligned box with figlet text:
figlet right-aligned | boxes -d unicornthink | boxes -s $COLUMNS -c x -a hr -i none | sed -e 's/^x/ /'
The basic idea is to call boxes twice, the second time with only a few x
in the first column of the result, which we remove again with the cut
command. In this way, boxes centers the box.
Some googling gave me that one might use $(tput cols)
instead of $COLUMNS
for slightly better coverage of different shells.
from boxes.
well i guess that works, a lotta extra work over just a flag. Actually if this is going to be the recommended approach, maybe there could be a blank "box" that prints nothing, is only for alignment purposes and is appropriately named, so that the command chain gets cut down to:
figlet right-aligned | boxes -d unicornthink | boxes -s $COLUMNS -d align -a hr
Saving a sed or cut command, making this a lot more discoverable and easier to figure out independently. A box that prints nothing should be easy enough for me to write actually.
from boxes.
In order to make this easier to discover, I added a section to the FAQ.
While trying out the commands above, I found that a blank box actually causes an error boxes may not consist entirely of whitespace
. I'll open a new issue as a reminder to myself to find out why that is. Maybe we can enable a new use case for boxes.
In general, unix philosophy says that tools should do one thing, and do it well. So, aligning stuff in a terminal window should be a task for another tool. (On Mac, fmt
is supposed to be able to do that.) It would be hard for boxes to reliably determine the terminal width on all of the platforms it runs on. For example, I wouldn't know how to do this on Windows.
from boxes.
I guess the blank box for formatting would handle this well enough, closing in favor of the other ticket
from boxes.
Related Issues (20)
- compilation option request (static binary) HOT 6
- Update project license to GPL-3 HOT 1
- Boxes missing on RedHat 8 and 9 HOT 8
- Tests failing on x86_64-unknown-linux-musl HOT 28
- Portage reports build QA issues HOT 1
- Build fails with clang 16 HOT 2
- Clang support? HOT 5
- Error installing/building boxes 2.2.0 under brew HOT 8
- Add MacOS job to our GitHub Actions HOT 1
- Add Windows CI to our GitHub build workflow HOT 3
- v2.3.0 some tests not passed HOT 7
- Testsuite failing on i386 architecture? HOT 12
- Contact info for artist Joan Stark HOT 3
- Allow blank boxes when specified via `-c " "` HOT 5
- shell-init: error HOT 4
- pcre2 HOT 8
- Update (Ubuntu) Packages to v2 HOT 14
- Question/Clarification on License (GPL-2 vs. GPL-2+) HOT 2
- Spacing for Unicode Block characters is off HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boxes.