0

How can I make iTerm accept options (e.g. -r) after filenames? For example, I often delete folders and forget the -r option. iTerm will accept rm -r folder but not rm folder -r. Any way to make this work?

I think I have seen this work on ubuntu.

I am on macos 10.15.3 with iTerm 3.3.9 and zsh 5.7.1.

3

It's not up to iTerm, it's up to each individual command program (like rm, ls, etc) how to parse its arguments. The traditional convention in unix commands is to require options to come first (before positional parameters), but the GNU project has adopted a convention where they can come in any order (except that -- indicates the end of options). macOS avoids GNU software as much as possible (for licensing reasons), and uses mostly bsd versions of commands... which (mostly) follow the traditional options-first convention.

You can install GNU versions of commands if you want (e.g. with homebrew). But there's a problem: because the GNU versions are different, you risk breaking scripts that assume the macOS-standard commands. To avoid this conflict, GNU versions are usually prefixed with "g" (e.g. gawk instead of awk), so you'd have to get used to that instead.

So, my advice is to get used to putting options first. It's the way most of the commands on macOS work, and if you try to change it you're just going to create other problems.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .