BTS

Issue980

Title make sudo-command-line() restore cursor position
Priority feature Status resolved
Superseder Nosy List btittelbach, ft
Assigned To ft Topics zsh

Created on 2011-04-19.20:48:50 by btittelbach, last changed 2011-05-11.19:16:27 by ch.

Messages
msg3783 (view) Author: ch Date: 2011-05-11.19:16:25
We believe that your issue has been closed by the upload of
Version 0.3.89 of grml-etc-core from Christian Hofstaedtler <ch@grml.org>.
The explanation is attached below

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Wed, 11 May 2011 21:06:10 +0200
Source: grml-etc-core
Binary: grml-etc-core
Architecture: source all
Version: 0.3.89
Distribution: unstable
Urgency: low
Maintainer: Michael Prokop <mika@grml.org>
Changed-By: Christian Hofstaedtler <ch@grml.org>
Description: 
 grml-etc-core - core ecetera files for the grml system
Changes: 
 grml-etc-core (0.3.89) unstable; urgency=low
 .
   [ Frank Terbeck ]
   * [a3a39fe] zshrc: Removing d()
   * [e193e4a] zshrc: activate zsh lookup for all users
   * [dc4eb5b] Fixing ssl-cert-{sha512,sha256,sha1,md5}()
   * [42b4b5f] Add *.substvars to gitignore
   * [690a5be] Waste less space in window titles [Closes: issue979]
   * [204f0ba] Preserve cursor position with `sudo-command-line' [Closes: issue980]
 .
   [ Michael Prokop ]
   * [d3a3ea5] /etc/skel/.zshrc: provide improved rationalise-dot version by Mikael Magnusson
 .
   [ Ulrich Dangel ]
   * [72b956d] Depend on grml-scripts-core instead of grml-scripts.
   * [6ab1014] Revert "Depend on grml-scripts-core instead of grml-scripts."
   * [8670ff0] Recommend grml-scripts-core
 .
   [ Christian Hofstaedtler ]
   * [ed29215] Bump Standards-Version to 3.9.2 (no changes)
Checksums-Sha1: 
 c14ef64f47b2f192bc6345f196a0da07a11b2f16 1528 grml-etc-core_0.3.89.dsc
 34b1ef6eedee8d85d8d0190760a2779467ed983e 156641 grml-etc-core_0.3.89.tar.gz
 36ab21ad969533f7369631db975d3ff615c10341 156688 grml-etc-core_0.3.89_all.deb
Checksums-Sha256: 
 b6da2e887ade8447ae44c904f1784582ba1c33874d53bc394187dc2d24b1fbd0 1528 grml-etc-core_0.3.89.dsc
 2a3ef0897dd0c7a91d54e2f6b2e9b916346caaf9da399e984fcf460b6832a942 156641 grml-etc-core_0.3.89.tar.gz
 66aa5386c5fa5d2f045688ba8a004f7efe012367bae163e2d006919f2f12c271 156688 grml-etc-core_0.3.89_all.deb
Files: 
 665b35bb3fc82eb26760eece805fdfb1 1528 grml optional grml-etc-core_0.3.89.dsc
 72de9d22d2c4031d3a4c476a555f2d63 156641 grml optional grml-etc-core_0.3.89.tar.gz
 cc4115acb20d4f6aa0d934889fb9acc0 156688 grml optional grml-etc-core_0.3.89_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJNyt78AAoJEL7IfitBhWKafuUQALARLEcg3AJMmPGU/JVJiH8x
uLZnqEDGrSX6o+Yagg2r8PM+5SwnkPShg1rqvRf6tTq1Btc+qIuiysAl7ed+FRwR
uabJW7DYwNvWwCWfUHDvd1G1Z1EHMu/NF4SptRbtkTJMDFIEygCtYcYYZnC7P2V9
kKo1FzP/5Io/Onc47oWfncjlqUdamUQrlE1XBrWsgkeVQ3hGeFbs5fbTtoHJm8MK
kr81yc1tVpAwUtE1HR3oXwmuOGD/KcU7I7HaAIsvFpl2SVVKYmEd4LwolNzleaZO
007+7cp16Uk/s/88Xs//dEvBVXxYD1rgbAmsRup0lyFGP1nGutJfoZIrZlhsbCAA
8rhEfK7CpHHRPYnuvHEDJ4/B2EyUCNiahJvI/FaYbHCWdEir0KTOJvLbv7HW5PZy
55VsgaiaNa6Ys6d/W6rg7lKZ/oQOuJODHC2BJ2ItB3OI7PNnfjI04OFjHIx/kNwZ
b6Iet2pFQYu0D0sktX2TA8E1Sljtv/8Lva8pWtWXZgqA7UP3b3SfOuE+w3tImsVE
2eFrYtXJME2r9NYIUpnznmmKj14md8ZSzZTzpstPuZUcvPk5AeGRLShCjfMcD/ok
CMWCY5g08CqPtHx+cst1DGgzDlN+1W/l3/5xPBNMduQClaDWFmASlJj7/ZrZWAyu
Xl6rnYEbkBfts39sBuL9
=nLwr
-----END PGP SIGNATURE-----
msg3741 (view) Author: btittelbach Date: 2011-04-19.22:14:02
thanks for the super fast fix :-)
already download and am using the newest .zshrc now..
msg3737 (view) Author: ft Date: 2011-04-19.21:21:23
Bernhard Tittelbach wrote:
> none at all, looks fine to me :-)

<http://git.grml.org/?p=grml-etc-core.git;a=commitdiff;h=690a5be664cdfbd914582e4c59672426356250ea>
msg3735 (view) Author: btittelbach Date: 2011-04-19.21:09:47
none at all, looks fine to me :-)
msg3733 (view) Author: ft Date: 2011-04-19.21:02:21
Bernhard Tittelbach wrote:
> after using sudo-command-line, the CL-length will have increased by 5 chars. As
> the cursor position stays the same, this amounts to a cursor offset with respect
> to my typed test of 5 chars to the left.
>
> please increase CURSOR position by 5 chars (==strlen "sudo "), so cursorposition
> remains the same, relative to typed test
>
> proposal:
>
> sudo-command-line() {
>     [[ -z $BUFFER ]] && zle up-history
>     [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" && CURSOR=$((CURSOR+5))
> }

Good point. I'd like to have the code look a little clearer
though. Lengthy "... && ... && ..." chains are fine as one shot command
lines, but are not useful in real code. Thus:

sudo-command-line() {
    [[ -z $BUFFER ]] && zle up-history
    if [[ $BUFFER != sudo\ * ]]; then
        BUFFER="sudo $BUFFER"
        CURSOR=$(( CURSOR+5 ))
    fi
}

Objections?

Regards, Frank
msg3732 (view) Author: btittelbach Date: 2011-04-19.20:48:49
after using sudo-command-line, the CL-length will have increased by 5 chars. As
the cursor position stays the same, this amounts to a cursor offset with respect
to my typed test of 5 chars to the left.

please increase CURSOR position by 5 chars (==strlen "sudo "), so cursorposition
remains the same, relative to typed test

proposal:

sudo-command-line() {
    [[ -z $BUFFER ]] && zle up-history
    [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" && CURSOR=$((CURSOR+5))
}
History
Date User Action Args
2011-05-11 19:16:27chsetmessages: + msg3783
2011-04-19 22:14:14btittelbachsetstatus: chatting -> resolved
2011-04-19 22:14:02btittelbachsetstatus: fixed-in-git -> chatting
messages: + msg3741
2011-04-19 21:21:23ftsetmessages: + msg3737
2011-04-19 21:18:07ftsetstatus: chatting -> fixed-in-git
2011-04-19 21:09:47btittelbachsetmessages: + msg3735
2011-04-19 21:02:21ftsetstatus: unread -> chatting
messages: + msg3733
2011-04-19 20:49:14btittelbachsettopic: + zsh
2011-04-19 20:48:50btittelbachcreate