* Zsh can't do "echo -n" preceding vared <variable>
@ 2023-08-17 14:45 Budi
2023-08-17 14:53 ` Bart Schaefer
2023-08-17 15:13 ` Peter Stephenson
0 siblings, 2 replies; 5+ messages in thread
From: Budi @ 2023-08-17 14:45 UTC (permalink / raw)
To: Zsh Users
How come Zsh can't perform echo -n that precedes vared <variable>, as
output is only the vared variable's content preceded by none ?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Zsh can't do "echo -n" preceding vared <variable>
2023-08-17 14:45 Zsh can't do "echo -n" preceding vared <variable> Budi
@ 2023-08-17 14:53 ` Bart Schaefer
2023-08-17 15:13 ` Peter Stephenson
1 sibling, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2023-08-17 14:53 UTC (permalink / raw)
To: Budi; +Cc: Zsh Users
On Thu, Aug 17, 2023 at 7:45 AM Budi <budikusasi@gmail.com> wrote:
>
> How come Zsh can't perform echo -n that precedes vared <variable>, as
> output is only the vared variable's content preceded by none ?
ZLE (invoked by vared) wants to know exactly where the cursor is
positioned on the first line, so it returns to the leftmost column on
startup.
Instead of
echo -n "Stuff here"
vared var
You should be using
vared -p "Stuff here" var
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Zsh can't do "echo -n" preceding vared <variable>
2023-08-17 14:45 Zsh can't do "echo -n" preceding vared <variable> Budi
2023-08-17 14:53 ` Bart Schaefer
@ 2023-08-17 15:13 ` Peter Stephenson
2023-08-17 15:20 ` Bart Schaefer
1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2023-08-17 15:13 UTC (permalink / raw)
To: Budi, Zsh Users
> On 17/08/2023 15:45 Budi <budikusasi@gmail.com> wrote:
> How come Zsh can't perform echo -n that precedes vared <variable>, as
> output is only the vared variable's content preceded by none ?
So it sounds like what you're trying to do is output something on the
same line that will be used for the vared, but without it being part
of the edit. You can't do that by default as the line editor takes
over the whole screen line and will align back to the start.
What you can do is use "vared -p prompt" to output something at the
start of the line, which doesn't have that problem as vared knows
it's there.
Another thing you can do is set the NO_PROMPT_CR option, which
stops the line editor from performing the carriage return. It
has bad effects if you are editing multiple lines, however ---
this is the difference from other shells that is the reason
for the usual zsh behaviour. If you're sure the vared will only
be on a single line, you could set that option locally in a
function. However, I hope vared -p is what you really need.
pws
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Zsh can't do "echo -n" preceding vared <variable>
2023-08-17 15:13 ` Peter Stephenson
@ 2023-08-17 15:20 ` Bart Schaefer
2023-08-17 23:00 ` Budi
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2023-08-17 15:20 UTC (permalink / raw)
To: Budi; +Cc: Zsh Users
On Thu, Aug 17, 2023 at 8:13 AM Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
>
> What you can do is use "vared -p prompt" to output something at the
> start of the line, which doesn't have that problem as vared knows
> it's there.
More generally, a key difference from bash+readline is that ZLE
manages the prompts as well as the input.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Zsh can't do "echo -n" preceding vared <variable>
2023-08-17 15:20 ` Bart Schaefer
@ 2023-08-17 23:00 ` Budi
0 siblings, 0 replies; 5+ messages in thread
From: Budi @ 2023-08-17 23:00 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh Users
vared -p BEGINNING var
works like a charm
THANKS SO MUCH!
On 8/17/23, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Thu, Aug 17, 2023 at 8:13 AM Peter Stephenson
> <p.w.stephenson@ntlworld.com> wrote:
>>
>> What you can do is use "vared -p prompt" to output something at the
>> start of the line, which doesn't have that problem as vared knows
>> it's there.
>
> More generally, a key difference from bash+readline is that ZLE
> manages the prompts as well as the input.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-17 23:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17 14:45 Zsh can't do "echo -n" preceding vared <variable> Budi
2023-08-17 14:53 ` Bart Schaefer
2023-08-17 15:13 ` Peter Stephenson
2023-08-17 15:20 ` Bart Schaefer
2023-08-17 23:00 ` Budi
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).