Abbreviates a string in the format of head
[...]tail
when it exceeds the length specified by width
. Useful for shortening
how filepaths are displayed.
Examples
a <- "/short/file/path/"
b <- "/much/longer/foooooooooooooooooooo/baaaaaaaaaaaaaaaaaaaar/file/path/"
str_abbreviate(c(a,b))
#> [1] "/short/file/path/"
#> [2] "/much/longer/fo[...]oo/baaaaaaaaaaaaaaaaaaaar/file/path/"
str_abbreviate(c(a,b), width = 10, head = 3, tail = 3)
#> [1] "/sh[...]ath/" "/mu[...]ath/"