🖥️boxes
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the boxes command with important options and switches using examples.
12 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ██████╗ ██╗ ██╗███████╗███████╗
# ██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔════╝
# ██████╔╝██║ ██║ ╚███╔╝ █████╗ ███████╗
# ██╔══██╗██║ ██║ ██╔██╗ ██╔══╝ ╚════██║
# ██████╔╝╚██████╔╝██╔╝ ██╗███████╗███████║
# ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝
boxes -l | less
# Welche Rahmenstile das Programm bereithält, verrät es mit der Option -l (list). Auch diese Liste schaut man sich besser seitenweise an
boxes -d boxname alt neu
# Mit dem Parameter -d wählen Sie den gewünschten Stil
boxes -d boxname alt neu
# alt ist der Name der Originaldatei und neu der Name der gerahmten Ausgabedatei. Alternativ arbeitet das Tool auch mit der Standardein- und -ausgabe des Terminals
echo "Dies ist ein C-Kommentar"|boxes -d c-cmt2
/* Dies ist ein C-Kommentar */
# Hier zeigt sich boxes von einer höchst praktischen Seite: Das Tool zeichnet nicht nur Zierrahmen, sondern beherrscht auch die Kommentarstile zahlreicher Programmiersprachen. Dazu integriert man boxes am besten in den Text-Editor. Wie das in Jed und den üblichen Verdächtigen, Vim und Emacs, geht und auch wie Sie eigene Rahmen entwerfen, erfahren Sie auf der Boxes-Projektseite [2].
# Bei größeren Boxen (z. B. dem Rahmenstil dog in Abbildung 4) mit wenig Inhalt ist es sinnvoll, die Satzausrichtung zu definieren. Die Option -a leitet die Ausrichtung ein, gefolgt von c, r oder l (zentiert, rechts, links).
# Den Abstand zwischen Text und Rahmen bestimmt die Option -p (Padding), die Sie um Richtungsangabe und Zeichenzahl ergänzen. Zum Beispiel bedeutet -pa5t3r1: Der Inhalt ist in jeder Richtung fünf Zeichen vom Rahmen entfernt (a5). Lediglich vom oberen Rand trennen ihn drei Zeilen (t3) und vom rechten sogar nur ein Zeichen (r1). Folgende Angaben sind zusammen mit -p möglich:
# a: In alle Richtungen
# b: Zum Boden der Box
# h: In horizontaler Richtung
# l: Zur linken Seite der Box
# r: Zur rechten Seite der Box
# t: Zum Kopf (top) der Box
# v: In vertikaler Richtung
# Einen starren Rahmen, unabhängig vom Text, geben Sie mit der Option -s (size) vor. Im folgenden Beispiel erzwingen wir eine Box, die neun Zeichen breit und drei Zeilen hoch ist:
echo LINUX | boxes -s 9x3 -d shell
#########
# LINUX #
#########
# Der letzte wichtige Parameter lautet -r (remove). Mit ihm löschen Sie falsch gewählte oder unpassende Boxen, ohne den Inhalt anzutasten. boxes erkennt dabei automatisch den Rahmenstil und entfernte im Test sogar doppelte Rahmen mühelos.
### Default action
boxes
/**************************/
/* Different all twisty a */
/* of in maze are you, */
/* passages little. */
/**************************/
# Draws a standard box of the first valid design found in your config file. If you have the config file as it comes with the boxes distribution, you get a "C" box, as you can see above.
### Choosing a different design
boxes -d parchment
________________________
/\ \
\_|Different all twisty a|
|of in maze are you, |
|passages little. |
| ___________________|_
\_/_____________________/
The -d design_name option selects another design from your config file.
### Positioning of text inside box
boxes -d diamonds -a hcvc
/\ /\ /\
/\//\\/\ /\//\\/\ /\//\\/\
/\//\\\///\\/\//\\\///\\/\//\\\///\\/\
//\\\//\/\\///\\\//\/\\///\\\//\/\\///\\
\\//\/ \/\\//
\/ \/
/\ Different all twisty a /\
//\\ of in maze are you, //\\
\\// passages little. \\//
\/ \/
/\ /\
//\\/\ /\//\\
\\///\\/\//\\\///\\/\//\\\///\\/\//\\\//
\/\\///\\\//\/\\///\\\//\/\\///\\\//\/
\/\\//\/ \/\\//\/ \/\\//\/
\/ \/ \/
The -a format option can be used to position the input text inside a box which is larger than needed for our text. hcvc stands for "horizontally centered, vertically centered".
Note that the box was drawn in this size because the shapes that compose it are very big, so that it is not possible to fit the box tighter around our text. Note also that the input lines themselves are not centered; hc only centers the input text block as a whole.
### Line justification
boxes -d simple -a jr
************************
*Different all twisty a*
* of in maze are you,*
* passages little.*
************************
# This uses the third possible argument to the -a option, j. jr stands for "justification right".
### Quick alignment/positioning
boxes -d dog -a c
# __ _,--="=--,_ __ "
# / \." .-. "./ \
# / ,/ _ : : _ \/` \
# \ `| /o\ :_: /o\ |\__/
# `-'| :="~` _ `~"=: |
# \` (_) `/
# .-"-. \ | / .-"-.
#.---{ }--| /,.-'-.,\ |--{ }---.
# ) (_)_)_) \_/`~-===-~`\_/ (_(_(_) (
#( Different all twisty a )
# ) of in maze are you, (
#( passages little. )
# ) (
#'---------------------------------------'
# Since noone really wants to type -a hcvcjc only to actually center text inside a box, there are shorthand notations (l, c, and r).
# Note the blank line at the bottom of the box (after little, but before the dashes) which is necessary to make the bottom of the box look right. If the blank line was not there, the box would end on a closing parenthesis, thus looking broken.
### Box size specification
boxes -d html -s 40
<!-- ------------------------------- -->
<!-- Different all twisty a -->
<!-- of in maze are you, -->
<!-- passages little. -->
<!-- ------------------------------- -->
# Using -s 40, we have set the box width to 40 characters.
### Box size specification (2)
boxes -d peek -a c -s 40x11
/* _\|/_
(o o)
+----oOO-{_}-OOo----------------------+
| |
| |
| Different all twisty a |
| of in maze are you, |
| passages little. |
| |
| |
+------------------------------------*/
# Using -s 40x11, you can set both width and height. Setting just the height is possible with -s x11 (note the leading x on the argument).
### Text Padding
boxes -d shell -p a1l2
###########################
# #
# Different all twisty a #
# of in maze are you, #
# passages little. #
# #
###########################
# Normally, the padding values depend on the design. The "shell" design has no default padding, so we can see the effects of our command line option unchanged. a1l2 stands for "all 1, left 2", and tells boxes to put one space (or empty line, in the vertical direction) around the input text block, except for the left side where two spaces shall be used.
### Text Padding (2)
boxes -p h0v0
/************************/
/*Different all twisty a*/
/*of in maze are you, */
/*passages little. */
/************************/
# This uses again the default design, which by default features a horizontal padding value of one space (as you know from the very first example). By specifying -p h0v0, we set all padding to zero ("horizontal 0, vertical 0"). In this case, the same could have been achieved by -p h0 or -p a0.
### Regional comments
# Imagine you want to comment out the following C code:
if (!s2 || *s2 == '\0')
return (char *) s1; /* error 1 */
if (!s1 || *s1 == '\0')
return NULL; /* error 2 */
if (skip < 0)
skip = 0; /* foo bar */
boxes -d c-cmt
/* if (!s2 || *s2 == '\0') */
/* return (char *) s1; /* error 1 *\/ */
/* if (!s1 || *s1 == '\0') */
/* return NULL; /* error 2 *\/ */
/* if (skip < 0) */
/* skip = 0; /* foo bar *\/ */
# Note that the closing comment tags in the input text have been escaped by adding a backslash between the asterisk and the slash. This way, the comments that have been commented out along with the rest of the code will not interfere with the new comments.
boxes -r
if (!s2 || *s2 == '\0')
return (char *) s1; /* error 1 */
if (!s1 || *s1 == '\0')
return NULL; /* error 2 */
if (skip < 0)
skip = 0; /* foo bar */
# Should you decide to reactivate the code previouly commented out, the escaped closing comment tags are changed back into normal ones. This is achieved by the replace and reverse statements in the config file entry describing this particular box design. If you want this to work recursively, simply add more such statements.
### Box removal
# Imagine your once beautiful box in "C" style like this in your editor, after you are done editing the text inside:
/********************************************************************/
/* Generate sorted listing of available box styles.
Uses design name from BOX spec and sample picture plus author.
*/
/* RETURNS: != 0 on error (out of memory) */
== 0 on success */
/********************************************************************/
boxes -r
# Generate sorted listing of available box styles.
# Uses design name from BOX spec and sample picture plus author.
RETURNS: != 0 on error (out of memory)
== 0 on success
# The box is correctly removed even though it’s been badly damaged by editing of the text inside. Obviously, the box design was correctly autodected as being "C". Note there is only a single leading space in the output text, whereas there are two leading spaces in the input text. This is because the "C" box design has a default horizontal padding of one space. Since boxes assumes it has added the padding space, it also attempts to removes the same number of spaces when removing the box. Thus, if you were to add a new box around the text, the box internal indentation would be retained. It is easily possible to use this feature to make an editor key mapping which repairs a box for you (see installation in the documentation section).
### Box removal (2)
# Imagine an HTML comment box like the follwing, and imagine that boxes does not correctly autodetect it as being an HTML box:
<!-- - - - - - - - - - - - - -->
<!-- Different all twisty a -->
<!-- of in maze are you, -->
<!-- passages little. -->
<!-- - - - - - - - - - - - - -->
boxes -r -d html
# Different all twisty a
# of in maze are you,
# passages little.
# In cases where design autodetection fails, -d design_name can be added to the -r command in order to tell boxes which design exactly to remove. It is always a good thing to use the -d option, because it makes autodetection unnecessary. Autodetection takes more time, because the entire config file must be parsed instead of just the one design needed, and all designs must be matched against the input text in order to see which one fits best.
### Indentation handling
# For this example, our input text is indented by four spaces:
Different all twisty a
of in maze are you,
passages little.
boxes -d java-cmt -i box
// Different all twisty a
// of in maze are you,
// passages little.
# The default indent mode is box, which indents the box by the same value as the input text was indented. As shown here, this is useful when adding regional comments to your source code, e.g. when "commenting out" a large portion of your code. Most people generally prefer to indent comments by the same value as the code they refer to, so they don’t upset the code structure.
boxes -d vim-cmt -i text
" Different all twisty a
" of in maze are you,
" passages little."
# By specifying -i text, the box is made to start at column zero and any input text indentation is retained inside the box.
boxes -d pound-cmt -i none
# Different all twisty a
# of in maze are you,
# passages little.
# Finally, it is also possible to throw away any indentation altogether by specifying -i none.
### Use of Regular Expressions
# Global Variables
boxes -d headline
/*************************************/
/* G l o b a l V a r i a b l e s */
/*************************************/
# The replace and reverse statements may contain regular expressions and backreferences, which can be used for more elaborate text modifications. The example shown here, where spaces are inserted between the individual characters, is configured like this.
boxes -d headline -r
Global Variables
twisted
stark1
diamonds
shell
$ cat greeting.txt | boxes -d diamonds -a c
Which will give us the output as follows:
/\ /\ /\
/\//\\/\ /\//\\/\ /\//\\/\
/\//\\\///\\/\//\\\///\\/\//\\\///\\/\
//\\\//\/\\///\\\//\/\\///\\\//\/\\///\\
\\//\/ \/\\//
\/ \/
/\ I'm wishing you all a /\
//\\ joyous holiday season //\\
\\// and a Happy Gnu Year! \\//
\/ \/
/\ /\
//\\/\ /\//\\
\\///\\/\//\\\///\\/\//\\\///\\/\//\\\//
\/\\///\\\//\/\\///\\\//\/\\///\\\//\/
\/\\//\/ \/\\//\/ \/\\//\/
\/ \/ \/
Or perhaps something more fun, like:
echo "I am a dog" | boxes -d dog -a c
Which will, unsurprisingly, give you the following:
__ _,--="=--,_ __
/ \." .-. "./ \
/ ,/ _ : : _ \/` \
\ `| /o\ :_: /o\ |\__/
`-'| :="~` _ `~"=: |
\` (_) `/
.-"-. \ | / .-"-.
.---{ }--| /,.-'-.,\ |--{ }---.
) (_)_)_) \_/`~-===-~`\_/ (_(_(_) (
( I am a dog )
) (
'---------------------------------------'
Boxes comes with lots of options for padding, position, and even processing regular expressions. You can learn more about boxes on the project's homepage, or head over to GitHub to download the source code or contribute your own box. In fact, if you're looking for an idea to submit, I've got an idea for you: why not a holiday present?
_ _
/_\/_\
_______\_\/_/_______
| ///\\\ |
| /// \\\ |
| |
| "Happy pull |
| request!" |
|____________________|
[email protected]:~$ figlet -w 120 hotline-nws.sh | boxes -d peek | boxes -d shell -p a1l2
############################################################################
# #
# _\|/_ #
# (o o) #
# +----oOO-{_}-OOo-----------------------------------------------------+ #
# | _ _ _ _ _ | #
# || |__ ___ | |_| (_)_ __ ___ _ ____ _____ ___| |__ | #
# || '_ \ / _ \| __| | | '_ \ / _ \_____| '_ \ \ /\ / / __| / __| '_ \ | #
# || | | | (_) | |_| | | | | | __/_____| | | \ V V /\__ \_\__ \ | | || #
# ||_| |_|\___/ \__|_|_|_| |_|\___| |_| |_|\_/\_/ |___(_)___/_| |_|| #
# | | #
# +-------------------------------------------------------------------*/ #
# #
############################################################################
#==============================##==============================#
# CMD boxes #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command boxes in a clear format. This allows users to quickly access the needed information for boxes without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for boxes are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.