fish-shell/share
Fabian Boehm 41c22d5e60 Add string shorten
This is essentially the inverse of `string pad`.
Where that adds characters to get up to the specified width,
this adds an ellipsis to a string if it goes over a specific maximum width.
The char can be given, but defaults to our ellipsis string.
("…" if the locale can handle it and "..." otherwise)

If the ellipsis string is empty, it just truncates.

For arguments given via argv, it goes line-by-line,
because otherwise length makes no sense.

If "--no-newline" is given, it adds an ellipsis instead and removes all subsequent lines.

Like pad and `length --visible`, it goes by visible width,
skipping recognized escape sequences, as those have no influence on width.

The default target width is the shortest of the given widths that is non-zero.

If the ellipsis is already wider than the target width,
we truncate instead. This is safer overall, so we don't e.g. move into a new line.
This is especially important given our default ellipsis might be width 3.
2022-09-09 18:49:57 +02:00
..
completions Add string shorten 2022-09-09 18:49:57 +02:00
functions prompt_pwd: Escape $HOME 2022-09-04 09:18:57 +02:00
groff
tools disco prompt: Pad hash 2022-08-27 16:38:36 +02:00
__fish_build_paths.fish.in
config.fish share/config.fish: Fix outdated comment 2022-08-11 17:07:59 +02:00
lynx.lss