[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: trap DEBUG and $_
From: |
isabella parakiss |
Subject: |
Re: trap DEBUG and $_ |
Date: |
Mon, 12 Oct 2015 07:24:00 +0200 |
On 10/11/15, Dan Stromberg <dstromberglists@gmail.com> wrote:
> Is there a way of outputting a datestamp to shell stderr at the _beginning_
> of the execution of a command, that won't wipe out $_?
>
> I use $_ quite a bit for the last argument to the previous command,
> interactively. And I'd like to datestamp all my commands. Datestamping
> after with $PS1 is easy, but datestamping before is a little harder.
>
> I've tried using:
>
> function preexec { if tty -s; then echo "$(tput smso)cmd started $(date
> +%Y\ %a\ %b\ %d\ %r)$(tput rmso)"; fi; }
> trap preexec DEBUG
>
> ...but as you might suspect, I'm finding that $_ is always "preexec" with
> this enabled.
>
> Any suggestions?
>
> Thanks!
>
trap '__=$_; preexec; : "$__"' DEBUG
---
xoxo iza
- trap DEBUG and $_, Dan Stromberg, 2015/10/15
- Re: trap DEBUG and $_,
isabella parakiss <=