Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 3
    I've found the default binding Alt+t to work both in bash and zsh to transpose the most recent two words. This is cool for simple args like flags (which are usually order independent! ha!), but when given a path, this does the (possibly useful, but largely not) transposition of the last 2 dirs in the path, not the entire paths themselves. And even if it could group by actual Word, it'd probably fail to properly abide by paths with spaces in them entered with escaped spaces. Commented Jan 9, 2020 at 21:41
  • Note that it is actually the shell that's actually tokenizing the arguments to pass to the system API. The system APIs for starting processes only takes an executable path and list of strings; except for system(), where the system will actually just spawn the default shell (/bin/sh) to tokenize the string and call back to the proper process API. Commented Jan 10, 2020 at 6:35
  • 1
    You mention being adept in this reordering in vim itself. Have you put your shell/read line in vi mode already? You can edit the current command line in EDITOR by hitting v and reorder arguments the way you're used to. Commented Jan 10, 2020 at 12:29
  • 1
    Just an idea, since it sounds like you are already a heavy fzf user: would it be enough to have a function (also bound to a keystroke?) that takes all the arguments from the last command, and pipes them through fzf, and lets you multi-select the ones you want to keep, in the order you want to keep them? (In my experience, the output of fzf is in the order that the items were selected.) Commented Jan 10, 2020 at 21:04
  • 1
    @iconoclast I like your out-of-the-box thinking, that is a clever alternate way to approach it (similar to opening the command as a buffer in vim). It's really a bit more heavy-handed than the immediate behavior I'm looking for. But, it would be well suited to some other situations where heavy buffer editing is desired. Commented Jan 10, 2020 at 21:20