From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9263 invoked from network); 10 Aug 2021 21:56:58 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Aug 2021 21:56:58 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1628632618; b=Yl2G6INiB9SDlxXhyz627QsvJh4uKRDqZ/jJs8Cb6JuXSLhU4e2MqYVJ/9eq6p1BYrqEAmtEKV j1S7IIQJjkNa3i1trEJUNMH2NRvM03QfzicYPOOfkqb6yArx87SLng6coRVaPk4I0z3zMjQ0I3 09FdYfY1BZUQCI+xzc0y16gzwvfYeG5R3w5eBTJsR17u8MtuM2iqOUhzTUd2kVJwZyECfa4P+l JONFzCmB1x3PHd36XfnxD/ye4ayHuP9N/8aSK5hOC2an13sS1DOvgIdkXZBUIw20PlJZcfa3Kn i6RJNYjrZvYKih6MonQrGcEFNGU5YHqzj15rEPHIUDCgmw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f54.google.com) smtp.remote-ip=209.85.208.54; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1628632618; bh=viiH+4QVMzkSDxuriiHjafo6arEzkphmoEfWwHTaTXw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID: References:Cc:To:From:Subject:DKIM-Signature:DKIM-Signature; b=b8tutFa1YHtSoMm/F4qeGm+6RwJbEXoKbixAHi3gxF5kLbabphAeJL7PVhn615WlIvgnjmGqPW KvCWjc3pR8Jk3Ehptq+LNFPt3G9btOKrIZunDRuEx7ID17oniMPLvZezPJDwaLzvam7/NOUIPb qM3xcGElVMcO1WB8nWTxtEY1XdUOYLfzvwvTWjfu7fnnq4tR7k5ZpQ2fbblzGLhSxdk315g+Xk ATrcaZssfiJjevMaH3jXP5Y9DH5L2yV8RRpkCRDjREk9yg64xh0B9ItZhTfClcD31rLlMhJGB8 RqFi1RgxpI/5gQwdWaT2vUu69B1vaBf01J5ls8ODMffJ6Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:In-Reply-To:MIME-Version :Date:Message-ID:References:Cc:To:From:Subject:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=DUQyu2dEeLkI8V0pSuI/q9q9bEuPyeWyjDNAViTh/KE=; b=Pfoecrr3BEEZ/7GMgqwLHMOX2k jWVLXpWoP3YlWJkYworAiY8UVzifawVyeiO7/DZAjvNaFDOUBbzHRdJlsP9Vpk/UTRisw+S9JKQ4n 8qa49czC8Oa5X0enJT0RUQD47GxY7oAeK3zGSTWaRDQj8yF26vZPa2/0SDsEAy9L3Wpe3UxSBHStH 2fz139GfrjX/DLX76eLJueLPyEIbJ2XQO3z0/6z6GQjvtWqjYAW/E33h0lWMHr49rWsdck9bwPV0D sudB7/1STEdWOEzf9F/ClpuIL6XrGZZ4HyGLElWjRaxxpKW/5yLb5BfCsNArlcOr1ZaIWmorg42wS ErwKJjVg==; Received: from authenticated user by zero.zsh.org with local id 1mDZk2-0005P2-RF; Tue, 10 Aug 2021 21:56:58 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f54.google.com) smtp.remote-ip=209.85.208.54; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ed1-f54.google.com ([209.85.208.54]:37591) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mDZh4-0004YS-50; Tue, 10 Aug 2021 21:53:54 +0000 Received: by mail-ed1-f54.google.com with SMTP id g21so301936edb.4 for ; Tue, 10 Aug 2021 14:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=DUQyu2dEeLkI8V0pSuI/q9q9bEuPyeWyjDNAViTh/KE=; b=KwJYlKBXIf6ZGIln2HIEmksZXZkyOtaRADjDDEjc2I9NXhOwZcuzmBhnYGdp8utf+W uFdlEsl50USjHbb7STLZlwHlqDq0OO00HnTKZQVK8x/QAFvOodspd7kzCI8RTY4VLeqd ml03Wnn7BUpS9X/p3ekJba/x+M6cAS4BK2Nl+o241XsTiIQZrW2v0MRzVCGqhSNgxyeR JWN3SPGYEPywfZSt3i04xZu0dsOeWIWltfu2NCwahSu2uOKR7zDZhEPp1QbE5btWVWe5 9CfsA6haY/VKiV4yoScbr6x5naUZ5exbPX+R/hdFgCxkPTxiWKuJFbbSCz5jpnCwPnoo AJrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=DUQyu2dEeLkI8V0pSuI/q9q9bEuPyeWyjDNAViTh/KE=; b=c4RzQQdA6EpYMK06rvNZfHnb3yEtKdzSaoVUYqYxU5hGDjUEHb2q8JsWvoTgTZC3rH BvHyYr+GxjPUegBu72PPA/tlcYqcQqdkTc4txiT3ZLFHcO7NpbiqbxfWXAlxEeS9XWHy yAoEX7N51FQvTuhPyCuQaguySpKtnCy9EgYSIUVx/Lf2G4TWbB6fIgh3bT5GfHI/hPGx LwKAjdrXqNbp9psRfKaE1HJZ3g/P5cBy0iJP24f2W9Qsbsv6C6a883+JBAIw5gqPwisv U0T4oZjyJ/vY+LMsBo2849jO4EAN7claDijqCP3M2BJFUMdoP98Uc5XO26J+gjB7Yj0I w5Hg== X-Gm-Message-State: AOAM533C76DWJ71W+Ghx3sA5Krp4hdtpATPzEt/A8tVVs6GPZ63lJUKq h162XEi4V3Yt0BcXZxneFxsdCDsWjb1jeQ== X-Google-Smtp-Source: ABdhPJz2D/HEqbXhH+m8aAWtwHIxmCW685yTnQN7ZSOTC0u5pxHqxx26zYGp6JpmVEfdbo2AzuwKYQ== X-Received: by 2002:a05:6402:141:: with SMTP id s1mr7407299edu.377.1628632433765; Tue, 10 Aug 2021 14:53:53 -0700 (PDT) Received: from ?IPv6:2001:16b8:682b:2900:f209:66bf:32ce:890a? (200116b8682b2900f20966bf32ce890a.dip.versatel-1u1.de. [2001:16b8:682b:2900:f209:66bf:32ce:890a]) by smtp.gmail.com with ESMTPSA id cb4sm7328617ejb.72.2021.08.10.14.53.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Aug 2021 14:53:53 -0700 (PDT) Subject: Re: Converting relative paths to full From: =?UTF-8?Q?G=c3=bcrkan?= To: Bart Schaefer Cc: Zsh Users References: <68cd3b1c-0a75-af79-f262-e5dd32233c55@gmail.com> Message-ID: <3c2e9d50-b7c5-6e59-c29f-3d175e7bf608@gmail.com> Date: Tue, 10 Aug 2021 23:53:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <68cd3b1c-0a75-af79-f262-e5dd32233c55@gmail.com> Content-Type: multipart/alternative; boundary="------------5CA11625B4A0E69258FC9D24" Content-Language: en-US X-Seq: 26902 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: This is a multi-part message in MIME format. --------------5CA11625B4A0E69258FC9D24 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 --------------5CA11625B4A0E69258FC9D24 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit


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
--------------5CA11625B4A0E69258FC9D24--