mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-26 14:01:13 -03:00
New command "string pad" to pad text to a given width (#7340)
Pads text to a given width, or the maximum width of all inputs.
This commit is contained in:
committed by
Johannes Altmanninger
parent
46746b4b26
commit
92511b09c4
@@ -42,6 +42,29 @@ string length "hello, world"
|
||||
string length -q ""; and echo not zero length; or echo zero length
|
||||
# CHECK: zero length
|
||||
|
||||
string pad foo
|
||||
# CHECK: foo
|
||||
|
||||
string pad -r -w 4 foo
|
||||
# CHECK: foo
|
||||
|
||||
string pad -r -w 7 -c '-' foo
|
||||
# CHECK: foo----
|
||||
|
||||
string pad --width 7 -c '=' foo
|
||||
# CHECK: ====foo
|
||||
|
||||
echo \|(string pad --width 10 --right foo)\|
|
||||
# CHECK: |foo |
|
||||
|
||||
string pad -w 4 -c . 🐟
|
||||
# CHECK: ..🐟
|
||||
|
||||
string pad -c . long longer longest
|
||||
# CHECK: ...long
|
||||
# CHECK: .longer
|
||||
# CHECK: longest
|
||||
|
||||
string sub --length 2 abcde
|
||||
# CHECK: ab
|
||||
|
||||
@@ -192,7 +215,7 @@ string unescape --style=url (string escape --style=url 'a b#c"\'d')
|
||||
# CHECK: a b#c"'d
|
||||
|
||||
string unescape --style=url (string escape --style=url \na\nb%c~d\n)
|
||||
# CHECK:
|
||||
# CHECK:
|
||||
# CHECK: a
|
||||
# CHECK: b%c~d
|
||||
|
||||
@@ -260,7 +283,7 @@ string replace -a " " _ "spaces to underscores"
|
||||
# CHECK: spaces_to_underscores
|
||||
|
||||
string replace -r -a "[^\d.]+" " " "0 one two 3.14 four 5x"
|
||||
# CHECK: 0 3.14 5
|
||||
# CHECK: 0 3.14 5
|
||||
|
||||
string replace -r "(\w+)\s+(\w+)" "\$2 \$1 \$\$" "left right"
|
||||
# CHECK: right left $
|
||||
@@ -295,7 +318,7 @@ and echo Unexpected exit status at line (status --current-line-number)
|
||||
# 'string match -r with empty capture groups'
|
||||
string match -r '^([ugoa]*)([=+-]?)([rwx]*)$' '=r'
|
||||
#CHECK: =r
|
||||
#CHECK:
|
||||
#CHECK:
|
||||
#CHECK: =
|
||||
#CHECK: r
|
||||
|
||||
@@ -575,13 +598,13 @@ printf '[%s]\n' (string collect one\n\n two\n)
|
||||
# CHECK: [two]
|
||||
printf '[%s]\n' (string collect -N one\n\n two\n)
|
||||
# CHECK: [one
|
||||
# CHECK:
|
||||
# CHECK:
|
||||
# CHECK: ]
|
||||
# CHECK: [two
|
||||
# CHECK: ]
|
||||
printf '[%s]\n' (string collect --no-trim-newlines one\n\n two\n)
|
||||
# CHECK: [one
|
||||
# CHECK:
|
||||
# CHECK:
|
||||
# CHECK: ]
|
||||
# CHECK: [two
|
||||
# CHECK: ]
|
||||
|
||||
Reference in New Issue
Block a user