From fcbd9730de9eba0c927ebb88ff9d7a395e41623d Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 9 Aug 2022 20:17:43 +0200 Subject: [PATCH] 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?) --- share/completions/git.fish | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index b05fca8ce..ea0115a74 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -732,8 +732,9 @@ function __fish_git_aliases begin set -l name (string replace -r '^.*\.' '' -- $key) # Only use the first line of the value as the description. - set -l val (printf '%s\n' $value)[1] - printf "%s\t%s\n" $name "Alias for $val" + # Also shorten it to 35 chars. + 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