From: Gürkan <seqizz@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Converting relative paths to full
Date: Wed, 11 Aug 2021 08:24:42 +0200 [thread overview]
Message-ID: <24f91d99-bedb-3fd1-2282-7ecddde432b6@gmail.com> (raw)
In-Reply-To: <CAH+w=7Y53fficKbrX_JGA6FeP1hcZDqJKjRmzC9Xd3s9nu=bxg@mail.gmail.com>
On 11/08/2021 00.36, Bart Schaefer wrote:
> That's far more complicated than necessary.
>
> function _edit_command_to_register_full_path {
> emulate -L zsh
> for element in ${(z)1}; do
> # Don't care about parameters
> [[ $element == -* ]] && continue
> FULLPATH="${element:P}"
> # Don't replace when already the full path
> [[ $element == $FULLPATH ]] && continue
> # Don't replace when path doesn't exist
> [[ -f $FULLPATH || -d $FULLPATH ]] || continue
> # [[:space:]] to protect previous replacements
> # (this is still not foolproof for path prefixes)
> set -- "${1/[[:space:]]$element/ $FULLPATH}"
> done
> print -Sr -- ${1%%$'\n'}
> return 1
> }
Thank you, that looks indeed much better.
I am still potato on shell builtins topic, will read and try to shorten
my 400-line rc file :)
prev parent reply other threads:[~2021-08-11 6:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 19:53 Gürkan
2021-08-10 20:44 ` Bart Schaefer
2021-08-10 21:39 ` Gürkan
2021-08-10 21:53 ` Gürkan
2021-08-10 22:36 ` Bart Schaefer
2021-08-11 6:24 ` Gürkan [this message]
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=24f91d99-bedb-3fd1-2282-7ecddde432b6@gmail.com \
--to=seqizz@gmail.com \
--cc=schaefer@brasslantern.com \
--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).