dotfiles/.config/fish/functions/__sf_util_truncate_dir.fish
2023-07-16 18:24:42 +02:00

17 lines
343 B
Fish

#
# Truncate directory
#
function __sf_util_truncate_dir -a path truncate_to -d "Truncate a directory path"
if test "$truncate_to" -eq 0
echo $path
else
set -l folders (string split / $path)
if test (count $folders) -le "$truncate_to"
echo $path
else
echo (string join / $folders[(math 0 - $truncate_to)..-1])
end
end
end