zsh-users
 help / color / mirror / code / Atom feed
* Prevent new line when using edit-command-line
@ 2021-11-08  7:17 Muhmud Ahmad
  2021-11-08 16:46 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Muhmud Ahmad @ 2021-11-08  7:17 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

When I use edit-command-line, my resulting command is always placed on a
new line.

For example, I am at my prompt, I trigger the editor and type ls, save and
quit. My resulting ls is now at a new prompt, rather than the one I used to
trigger the editor. As I use this a fair amount, it spaces out all the
commands and is kind of annoying.

Is there anyway to stop this behaviour, and just have my command on the
same line where I started the editor?


Thanks,

Muhmud.

[-- Attachment #2: Type: text/html, Size: 628 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Prevent new line when using edit-command-line
  2021-11-08  7:17 Prevent new line when using edit-command-line Muhmud Ahmad
@ 2021-11-08 16:46 ` Bart Schaefer
  2021-11-08 16:53   ` Muhmud Ahmad
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2021-11-08 16:46 UTC (permalink / raw)
  To: Muhmud Ahmad; +Cc: Zsh Users

On Sun, Nov 7, 2021 at 11:18 PM Muhmud Ahmad
<muhmud.ahmad@googlemail.com> wrote:
>
> Is there anyway to stop this behaviour, and just have my command on the same line where I started the editor?

I'm not able to reproduce this at the PS1 prompt, that is, for me the
buffer is restored at the current prompt.  At the PS2 prompt, starting
a new PS1 prompt is unavoidable because the existing ZLE "session" has
to be restarted in order to merge the previously-entered lines
($PREBUFFER) with the current line ($BUFFER).


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Prevent new line when using edit-command-line
  2021-11-08 16:46 ` Bart Schaefer
@ 2021-11-08 16:53   ` Muhmud Ahmad
  2021-11-08 16:54     ` Muhmud Ahmad
  0 siblings, 1 reply; 8+ messages in thread
From: Muhmud Ahmad @ 2021-11-08 16:53 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 842 bytes --]

Just tried this with "zfs -f", and I still get the same behaviour. I'm
definitely at a PS1 prompt, I'm triggering the editor before I type
anything on the current line at all.

My zsh version is 5.8 (x86_64-pc-linux-gnu)

On Mon, 8 Nov 2021 at 21:46, Bart Schaefer <schaefer@brasslantern.com>
wrote:

> On Sun, Nov 7, 2021 at 11:18 PM Muhmud Ahmad
> <muhmud.ahmad@googlemail.com> wrote:
> >
> > Is there anyway to stop this behaviour, and just have my command on the
> same line where I started the editor?
>
> I'm not able to reproduce this at the PS1 prompt, that is, for me the
> buffer is restored at the current prompt.  At the PS2 prompt, starting
> a new PS1 prompt is unavoidable because the existing ZLE "session" has
> to be restarted in order to merge the previously-entered lines
> ($PREBUFFER) with the current line ($BUFFER).
>

[-- Attachment #2: Type: text/html, Size: 1307 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Prevent new line when using edit-command-line
  2021-11-08 16:53   ` Muhmud Ahmad
@ 2021-11-08 16:54     ` Muhmud Ahmad
  2021-11-08 17:56       ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Muhmud Ahmad @ 2021-11-08 16:54 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

I meant "zsh -f"

On Mon, 8 Nov 2021 at 21:53, Muhmud Ahmad <muhmud.ahmad@googlemail.com>
wrote:

> Just tried this with "zfs -f", and I still get the same behaviour. I'm
> definitely at a PS1 prompt, I'm triggering the editor before I type
> anything on the current line at all.
>
> My zsh version is 5.8 (x86_64-pc-linux-gnu)
>
> On Mon, 8 Nov 2021 at 21:46, Bart Schaefer <schaefer@brasslantern.com>
> wrote:
>
>> On Sun, Nov 7, 2021 at 11:18 PM Muhmud Ahmad
>> <muhmud.ahmad@googlemail.com> wrote:
>> >
>> > Is there anyway to stop this behaviour, and just have my command on the
>> same line where I started the editor?
>>
>> I'm not able to reproduce this at the PS1 prompt, that is, for me the
>> buffer is restored at the current prompt.  At the PS2 prompt, starting
>> a new PS1 prompt is unavoidable because the existing ZLE "session" has
>> to be restarted in order to merge the previously-entered lines
>> ($PREBUFFER) with the current line ($BUFFER).
>>
>

[-- Attachment #2: Type: text/html, Size: 1722 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Prevent new line when using edit-command-line
  2021-11-08 16:54     ` Muhmud Ahmad
@ 2021-11-08 17:56       ` Bart Schaefer
  2021-11-08 19:14         ` Muhmud Ahmad
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2021-11-08 17:56 UTC (permalink / raw)
  To: Muhmud Ahmad; +Cc: Zsh Users

>> My zsh version is 5.8 (x86_64-pc-linux-gnu)

Ah, my apologies ... I'm using the edit-command-line function from the
latest git checkout.  It works fine in 5.8, grab it and drop it
somewhere early in your $fpath.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Prevent new line when using edit-command-line
  2021-11-08 17:56       ` Bart Schaefer
@ 2021-11-08 19:14         ` Muhmud Ahmad
  2021-11-08 22:29           ` Pier Paolo Grassi
  0 siblings, 1 reply; 8+ messages in thread
From: Muhmud Ahmad @ 2021-11-08 19:14 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

Yep, that works exactly as I want it to, thanks!

Any ideas when that will get released?

On Mon, 8 Nov 2021 at 22:57, Bart Schaefer <schaefer@brasslantern.com>
wrote:

> >> My zsh version is 5.8 (x86_64-pc-linux-gnu)
>
> Ah, my apologies ... I'm using the edit-command-line function from the
> latest git checkout.  It works fine in 5.8, grab it and drop it
> somewhere early in your $fpath.
>

[-- Attachment #2: Type: text/html, Size: 744 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Prevent new line when using edit-command-line
  2021-11-08 19:14         ` Muhmud Ahmad
@ 2021-11-08 22:29           ` Pier Paolo Grassi
  2021-11-08 23:05             ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Pier Paolo Grassi @ 2021-11-08 22:29 UTC (permalink / raw)
  To: Muhmud Ahmad; +Cc: Bart Schaefer, Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

It would be interesting to make it carry the position of the cursor in vim
to zsh. Vim saves the position of the cursor in .viminfo, so reading it
back from there is a possibility. Another possibility would be to instruct
vim to persist the same information recorded to .viminfo in some temporary
file, and then to read it back. Of course this would require some
configuration on vim's behalf, and not so simple to make it work on every
version, configuration and customization.
Any thoughts? maybe (probably) this has already surfaced

Pier Paolo Grassi


Il giorno lun 8 nov 2021 alle ore 20:15 Muhmud Ahmad <
muhmud.ahmad@googlemail.com> ha scritto:

> Yep, that works exactly as I want it to, thanks!
>
> Any ideas when that will get released?
>
> On Mon, 8 Nov 2021 at 22:57, Bart Schaefer <schaefer@brasslantern.com>
> wrote:
>
>> >> My zsh version is 5.8 (x86_64-pc-linux-gnu)
>>
>> Ah, my apologies ... I'm using the edit-command-line function from the
>> latest git checkout.  It works fine in 5.8, grab it and drop it
>> somewhere early in your $fpath.
>>
>

[-- Attachment #2: Type: text/html, Size: 1915 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Prevent new line when using edit-command-line
  2021-11-08 22:29           ` Pier Paolo Grassi
@ 2021-11-08 23:05             ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2021-11-08 23:05 UTC (permalink / raw)
  To: Pier Paolo Grassi; +Cc: Muhmud Ahmad, Zsh Users

On Mon, Nov 8, 2021 at 2:30 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> It would be interesting to make it carry the position of the cursor in vim to zsh.

Although you can't use "zed" as your edit-command-line editor, you can
use a shell function.  I think the above would best be implemented as
a wrapper around vim, which you can pass to (the current git head)
edit-command-line via the "editor" zstyle, e.g.,

zstyle :zle:edit-command-line editor vimwrapper

> Vim saves the position of the cursor in .viminfo

I don't find a .viminfo anywhere in my $HOME or $PWD after using vim
on my ubuntu host, so I can't experiment with this.  (It is "vim-tiny"
and only runs as "vi" so maybe that's why.)

edit-command-line goes to some lengths to preserve the region relative
to where it was in ZLE before the editor was started, so you probably
have to do something with "zle -U ..." to relocate the cursor after
vim is done.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-08 23:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08  7:17 Prevent new line when using edit-command-line Muhmud Ahmad
2021-11-08 16:46 ` Bart Schaefer
2021-11-08 16:53   ` Muhmud Ahmad
2021-11-08 16:54     ` Muhmud Ahmad
2021-11-08 17:56       ` Bart Schaefer
2021-11-08 19:14         ` Muhmud Ahmad
2021-11-08 22:29           ` Pier Paolo Grassi
2021-11-08 23:05             ` Bart Schaefer

Code repositories for project(s) associated with this 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).