News for hackers. Stuff that matters.
Re:Emacs: ffmpeg and macOS aliasing commands by p4bl0 on Sunday December 18, 2022 @12:26PM (#34039905)
My personal method is to type "ffmpeg" and then hit Ctrl+R repeatedly until I make it to the last time I used it to do what I want to do again now, and then adapt the command from history to my current needs.

It's not very efficient, but I don't feel it needs to be, and it requires no particular setup (except setting Bash to keep history forever but that's something useful I would do anyway for other use cases).

Re:Emacs: ffmpeg and macOS aliasing commands by tempodox on Sunday December 18, 2022 @02:04PM (#34041465)
By creating/editing `~/.inputrc` you can customize history navigation in bash. Enter `help bind` in bash to see an overview or consult [1].

A line like

  "\e[A": history-search-backward
only shows history entries that start with the current text when you hit cursor-up, for instance.

[1] https://www.gnu.org/savannah-checkouts/gnu/bash/manual/html_...

Re:Emacs: ffmpeg and macOS aliasing commands by BeetleB on Sunday December 18, 2022 @02:28PM (#34041813)
Ctrl+R combined with fzf is your friend :-)
Re:Emacs: ffmpeg and macOS aliasing commands by michaelcampbell on Sunday December 18, 2022 @03:21PM (#34042694)
Amen to that, I use almost nothing else these days except for when I have a new bespoke command I've never typed before. Even then fzf helps since I rarely am typing something COMPLETELY new.
Re:Emacs: ffmpeg and macOS aliasing commands by xenodium on Sunday December 18, 2022 @02:32PM (#34041876)
Ah, yes. This served me fairly well for some time. However, I also needed to remember the actual tool I used for the job. Was it ffmpeg? ffprobe? gifsicle? was it ImageMagick's convert? Not too bad if these are the only tools, but I also use pandoc, BluetoothConnector, pdftotext, qpdf, multiple AppleScripts, qrencode, system_profiler, fb-rotate, duti, sips, git... Bash history also remembers failed attempts, so I need to filter those out as I recall the successful one...

Wrapping the winning command with a memorable function makes it a bit easier for me to recall the right incantation via fuzzy searching. For example: "set default" (resolves to dwim-shell-commands-macos-set-default-app) vs "duti" (which I can never remember).

Re:Emacs: ffmpeg and macOS aliasing commands by gumby on Sunday December 18, 2022 @04:56PM (#34043988)
Why not do `history | grep ffmpeg`? Each line will be prefixed with its place in the history ("445 ffmpeg --whatever") and you can just press `!445` to run it.
Re:Emacs: ffmpeg and macOS aliasing commands by m463 on Sunday December 18, 2022 @06:19PM (#34045391)
I think control-r quietly automates a good portion of what I do.

As a matter of fact, I automatically (subconsciously) type control-r before every command.

I think I've only ever typed this command once:

  git log --graph --decorate --oneline --all
Re:Emacs: ffmpeg and macOS aliasing commands by p4bl0 on Monday December 19, 2022 @08:07AM (#34051580)
Ah, this precise command is aliased as `git lol` (Log One Line) for me!
Re:Emacs: ffmpeg and macOS aliasing commands by Y_Y on Sunday December 18, 2022 @07:05PM (#34046132)
I've found this is much more efficient if I add a comment at the end of the command describing what it does, then my C-r search can find that description, rather than just, say, any command in invoking some particular executable.
Re:Emacs: ffmpeg and macOS aliasing commands by dceddia on Sunday December 18, 2022 @07:49PM (#34046636)
If you haven’t run across Atuin yet you might like it! https://github.com/ellie/atuin

It stores shell history in a SQLite database and you can use Ctrl+R to fuzzy search it.