Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: "Pull just the text of a single command" (was Re: .zsh_history)



On Sat, Apr 15, 2023 at 3:47 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> IOW the only reason I use
> history is because it shows unexpanded commands. Show me how to do this
> with zle or preexec and I'll be in heaven.

I get the feeling something very like this has come through zsh-users
before, but:

autoload add-zsh-hook
hist-keep-raw-event() { print -rS -- "$1" }
hist-skip-expanded-event() { return 1 }
add-zsh-hook preexec hist-keep-raw-event
add-zsh-hook zshaddhistory hist-skip-expanded-event

This could be extended so that hist-skip-expanded-event only returns 1
if hist-keep-raw-event previously ran.  Or you could leave out
hist-skip-expanded-event entirely if you want access to both forms.




Messages sorted by: Reverse Date, Date, Thread, Author