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 workaround broken groff man page config 2016-10-19 13:43:04 -07:00
tools disco prompt: Pad hash 2022-08-27 16:38:36 +02:00
__fish_build_paths.fish.in Rename "snippets" to "conf" internally, and document them as snippets 2016-04-06 09:33:09 +08:00
config.fish share/config.fish: Fix outdated comment 2022-08-11 17:07:59 +02:00
lynx.lss Install custom LSS script to /usr/local/share/fish on make install 2017-09-26 14:31:11 -05:00