mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 02:27:28 +08:00
Improve string pad examples and add a cross-reference
The old examples were not really showcasing that it's nice for aligning text.
This commit is contained in:
parent
3002c88f44
commit
286ad97cbd
|
@ -44,6 +44,8 @@ Valid format specifiers are taken from the C library function ``printf(3)``:
|
|||
|
||||
Conversion can fail, e.g. "102.234" can't losslessly convert to an integer, causing printf to print an error. If you are okay with losing information, silence errors with `2>/dev/null`.
|
||||
|
||||
A number between the ``%`` and the format letter specifies the width. The result will be left-padded with spaces.
|
||||
|
||||
Backslash Escapes
|
||||
-----------------
|
||||
printf also knows a number of backslash escapes:
|
||||
|
|
|
@ -34,17 +34,22 @@ Examples
|
|||
|
||||
::
|
||||
|
||||
>_ string pad -w 10 abc
|
||||
>_ string pad -w 10 abc abcdef
|
||||
abc
|
||||
abcdef
|
||||
|
||||
>_ string pad --right --char=🐟 "fish are pretty" "rich. "
|
||||
fish are pretty
|
||||
rich. 🐟🐟🐟🐟
|
||||
|
||||
>_ string pad -w 6 -c- " | " "|||" " | " | string pad -r -w 9 -c-
|
||||
--- | ---
|
||||
---|||---
|
||||
--- | ---
|
||||
>_ string pad -w$COLUMNS (date)
|
||||
# Prints the current time on the right edge of the screen.
|
||||
|
||||
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- The :ref:`printf <cmd-printf>` command can do simple padding, for example ``printf %10s\n`` works like ``string pad -w10``.
|
||||
|
||||
.. END EXAMPLES
|
||||
|
|
Loading…
Reference in New Issue
Block a user