completions/git: Shorten alias descriptions

I have an alias called "lg" for

log --color --graph --pretty=format:\'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\' --abbrev-commit --first-parent

Having that in my completions ensures that git commands essentially
always use one column at most. That's not great, so we now shorten it
to 35 chars (plus an annoying 2 for ".." because I can't be bothered
to check for unicode support - an argument for a "string ellipsize", I guess?)
This commit is contained in:
Fabian Boehm 2022-08-09 20:17:43 +02:00
parent 2eae563b82
commit fcbd9730de

View file

@ -732,8 +732,9 @@ function __fish_git_aliases
begin begin
set -l name (string replace -r '^.*\.' '' -- $key) set -l name (string replace -r '^.*\.' '' -- $key)
# Only use the first line of the value as the description. # Only use the first line of the value as the description.
set -l val (printf '%s\n' $value)[1] # Also shorten it to 35 chars.
printf "%s\t%s\n" $name "Alias for $val" set -l val (printf '%s\n' $value | string replace -r '^(.{0,35}).+' '$1..')[1]
printf "%s\t%s\n" $name "Alias: $val"
end end
end end
end end