zsh-users
 help / color / mirror / code / Atom feed
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: Tue, 10 Aug 2021 23:53:52 +0200	[thread overview]
Message-ID: <3c2e9d50-b7c5-6e59-c29f-3d175e7bf608@gmail.com> (raw)
In-Reply-To: <68cd3b1c-0a75-af79-f262-e5dd32233c55@gmail.com>

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


On 10/08/2021 23.39, Gürkan wrote:
> But having a duplication problem. The original is still applied to history.
> Is there a way to just modify the string which is going to be accepted (thus respecting HIST* options),
> or should I give up this method and just use preexec_functions to modify the BUFFER directly?

Oh nevermind, I've found an old answer related to it[0]:

Now it works good enough:

	function _edit_command_to_register_full_path {
		emulate -L zsh

		REPLACED="$1"
		for element in `echo "$1"`; do
			# Don't care about parameters
			if [[ "$element" == -* ]]; then
				continue
			fi
			FULLPATH="${element:P}"
			if [[ -f $FULLPATH ]] || [[ -d $FULLPATH ]]; then
				REPLACED=`echo "$REPLACED" | sed "s!$element!$FULLPATH!"`
			fi
		done
	  print -Sr -- ${REPLACED%%$'\n'}
	  return 1
	}

	add-zsh-hook zshaddhistory _edit_command_to_register_full_path

Also needed to change -s to -S.

Thanks again.

[0]: https://www.zsh.org/mla/users/2011/msg00754.html

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

  reply	other threads:[~2021-08-10 21:56 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 [this message]
2021-08-10 22:36       ` Bart Schaefer
2021-08-11  6:24         ` Gürkan

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=3c2e9d50-b7c5-6e59-c29f-3d175e7bf608@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).