From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7480 invoked by alias); 20 Jul 2014 09:12:50 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18969 Received: (qmail 14280 invoked from network); 20 Jul 2014 09:12:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sternenrei.ch; s=default; t=1405847052; bh=BUxutHcaaASDxZI90y7Rojq0qkMyv6rRGVNFEI7IK5I=; h=Date:From:To:Subject:From; b=fvywMNI5nBlymq39uMTmWztA0TPxV88Y2uqWPPj0krpf2yQhJme2MKm+sviwqHWC6 mOQXubioP5w2chOoNZcjqW/K6t8wbWAk7yb7BMTFb3LfaPEVS89K8zGAXp4dCMi56j fm7lvnUNX3mVdND89yPDz2A+4iUJ6L5i6dBoMvIc= Message-ID: <53CB860C.8080509@sternenrei.ch> Date: Sun, 20 Jul 2014 11:04:12 +0200 From: Jochen Keil User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: zsh-users@zsh.org Subject: How to (properly) remove the last entry from history with command_not_found_handler X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pRusmJdJbWv7oRJuhjbtK71561wennxqI" --pRusmJdJbWv7oRJuhjbtK71561wennxqI Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Dear list, I'm trying to remove the last entry from my $HISTFILE when the command was not found. My current attempt involves the command_not_found_handler() hook: function command_not_found_handler() { sed -i '$d' $HISTFILE return 127 } However, I'm not sure if it's ok to manipulate the history file directly with sed, or if I'm risking corruption. Thank you very much and best wishes, Jochen --=20 To see a world in a grain of sand, And a heaven in a wild flower, Hold infinity in the palm of your hand, And eternity in an hour. - William Blake, Auguries of Innocence --pRusmJdJbWv7oRJuhjbtK71561wennxqI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlPLhgwACgkQtVwvsA+W4CAZXACdHLOj66zH+6fzilmp5vxnqm4R NSYAoIyf6+nODlrC3BhEexrDUGDifLPe =gUuW -----END PGP SIGNATURE----- --pRusmJdJbWv7oRJuhjbtK71561wennxqI--