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

How to see history 'expression' in history rather than the expansion?



Hi

ls IMG_20220612_093815.jpg

cp !$ /tmp

# but when I look at history I obviously see

ls IMG_20220612_093815.jpg

cp IMG_20220612_093815.jpg /tmp

# In this case !$ is trivial but sometimes I do an arbitrarily more complex history recall e.g.

cp !?imgxyz?$ /tmp

and I'd like to see that expression in my history (for reference purposes or to refine and correct it)

###### I've just remembered/realised that the following widget solves that. #####

###### But will still post this just to get any possible further advice #####

commit-to-history() {
# store a command in history for reuse w/o executing it
      print -s ${(z)BUFFER}
      zle send-break
}
zle -N commit-to-history
bindkey "^h" commit-to-history # ctrl-h


zzapper







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