2020-09-28 03:51:20 +08:00
string-pad - pad strings to a fixed width
=========================================
2020-09-28 01:12:42 +08:00
Synopsis
--------
.. BEGIN SYNOPSIS
2022-01-09 16:01:51 +08:00
`` string `` pad [**-r** | **--right** ] [(**-c** | **--char** ) *CHAR* ] [(**-w** | **--width** ) *INTEGER* ]
2022-01-09 18:03:31 +08:00
\ [*STRING* ...]
2020-09-28 01:12:42 +08:00
.. END SYNOPSIS
Description
-----------
.. BEGIN DESCRIPTION
2021-07-31 02:04:38 +08:00
`` string pad `` extends each STRING to the given visible width by adding CHAR to the left. That means the width of all visible characters added together, excluding escape sequences and accounting for $fish_emoji_width and $fish_ambiguous_width. It is the amount of columns in a terminal the STRING occupies.
The escape sequences reflect what *fish* knows about, and how it computes its output. Your terminal might support more escapes, or not support escape sequences that fish knows about.
2020-09-28 01:12:42 +08:00
2020-09-28 03:51:20 +08:00
If `` -r `` or `` --right `` is given, add the padding after a string.
2020-09-28 01:12:42 +08:00
2020-09-28 03:51:20 +08:00
If `` -c `` or `` --char `` is given, pad with CHAR instead of whitespace.
2020-09-28 01:12:42 +08:00
2020-09-28 03:51:20 +08:00
The output is padded to the maximum width of all input strings. If `` -w `` or `` --width `` is given, use at least that.
2020-09-28 01:12:42 +08:00
.. END DESCRIPTION
Examples
--------
.. BEGIN EXAMPLES
::
2020-09-29 00:42:02 +08:00
>_ string pad -w 10 abc abcdef
2020-09-28 01:12:42 +08:00
abc
2020-09-29 00:42:02 +08:00
abcdef
2020-09-28 01:12:42 +08:00
2020-09-28 03:51:20 +08:00
>_ string pad --right --char=🐟 "fish are pretty" "rich. "
fish are pretty
rich. 🐟🐟🐟🐟
2020-09-28 01:12:42 +08:00
2020-09-29 00:42:02 +08:00
>_ string pad -w$COLUMNS (date)
# Prints the current time on the right edge of the screen.
2020-09-28 01:12:42 +08:00
2020-09-29 00:42:02 +08:00
See Also
--------
- The :ref: `printf <cmd-printf>` command can do simple padding, for example `` printf %10s\n `` works like `` string pad -w10 `` .
2021-07-31 02:04:38 +08:00
- :ref: `string length <cmd-string-length>` with the `` --visible `` option can be used to show what fish thinks the width is.
2020-09-28 01:12:42 +08:00
.. END EXAMPLES