zsh-users
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: create variable with calculated number of spaces.
Date: Tue, 7 May 2024 07:52:10 +0200	[thread overview]
Message-ID: <CAN=4vMpQ1UYZC0T6_ago_UgTLE99TWbgG9X=YRybz839iD-8-w@mail.gmail.com> (raw)
In-Reply-To: <2c187631-8284-4f35-a1a2-f982e42dd704@eastlink.ca>

On Tue, May 7, 2024 at 7:15 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> ... 'findmnt' outputs nice columns so the thing is to space the
> 'title' line accordingly -- it's mostly the mountpoint who's width
> can vary so the spacer goes in there.  Purely cosmetic.

You don't need to "cobble together complicated variables" here. Just
printf straight away to stdout.

On the occasion when you do need to justify/pad a parameter without
printing, you can use `printf -v` or this:

    % n=10
    % y=${(r:n:: :)}  # n spaces
    % x='hello'
    % z=${(r:n:: :)x}  # right-justified x

There is also l (lower-case L) for left-justification.

Roman


  reply	other threads:[~2024-05-07  5:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 22:03 Ray Andrews
2024-05-06 22:33 ` Mark J. Reed
2024-05-06 22:35   ` Mark J. Reed
2024-05-06 22:38     ` Mark J. Reed
2024-05-06 23:02       ` Ray Andrews
2024-05-06 23:28         ` Mark J. Reed
2024-05-06 23:41           ` Ray Andrews
2024-05-06 23:57       ` Lawrence Velázquez
2024-05-07  5:14         ` Ray Andrews
2024-05-07  5:52           ` Roman Perepelitsa [this message]
2024-05-07 14:56             ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN=4vMpQ1UYZC0T6_ago_UgTLE99TWbgG9X=YRybz839iD-8-w@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).