Hello, I usually run the same command with async-shell-command, however I have to navigate back to the last command history to trigger my last run command, is there any way async-shell-command (and shell-command) can autofill with last run command so that I just hit enter without extra steps?

  • abbreviatedman@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Slight improvement on your advising function, OP: this version starts the shell history you scroll through at index 1, so that after you go up one from your most recent-command, you don’t see the most recent command again.

    (defun crj--auto-fill-shell-commands (args)
      (list (car args) (car shell-command-history) '(shell-command-history . 1) (cdddr args)))
    
    (advice-add 'read-shell-command :filter-args #'crj--auto-fill-shell-commands)
    

    Is there a cleaner way to handle the args than this unpleasing cdddr? Something I can do with &rest?