this post was submitted on 18 Oct 2023
1 points (100.0% liked)

Emacs

305 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] abbreviatedman@alien.top 1 points 11 months 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?