dotfiles/private_dot_config/private_fish/functions/fcd_shortest.fish
2023-04-30 01:21:51 +03:00

20 lines
353 B
Fish

function fcd_shortest -d 'Return the shortest string in array'
set -l args
if not tty >/dev/null
read args
else
set args $argv
end
set -l lines
for str in $args
if test (string length $str) -gt 0
set lines $lines "$str"
end
end
for line in $lines
echo (string length "$line") "$line"
end | sort -n | head -1 | cut -d' ' -f2-
end