Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ivy-occur for counsel-find-file doesn't work on BSDs (including OSX) #1686

Closed
PuercoWork opened this issue Jul 27, 2018 · 5 comments

Comments

@PuercoWork
Copy link

commented Jul 27, 2018

The commit 0d2823e uses the -d option which is specific to GNU's xargs. So trying to use ivy-occur results in following error

  /Users/puercopop/.emacs.d/elpa/counsel-20180723.854/:
  ls -a | grep -i -E '' | xargs -d '\n' ls -d --group-directories-first -alh | sed -e "s/^/  /"
xargs: illegal option -- d
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jul 30, 2018

The change applied only to counsel-find-file-occur-cmd, which is customizable by users.

Just add this to your config:

(setq counsel-find-file-occur-cmd "ls -a | grep -i -E '%s' | xargs ???")

I would also appreciate a PR like this:

(defvar counsel-find-file-occur-cmd
  (if (eq system-type 'darwin)
      "???"
    "ls -a | grep -i -E '%s' | xargs -d '\\n' ls -d --group-directories-first")
  "Format string for `counsel-find-file-occur'.")

This would initialize the variable to a value suitable for OSX. Unfortunately, I don't have OSX so I can't make the change myself.

@PuercoWork

This comment has been minimized.

Copy link
Author

commented Jul 30, 2018

The ??? that works for me is "ls -a | grep -i -E '%s' | xargs ls -d". However that wouldn't fix the but that -d \\n attempts to fix. I'll look for a proper fix, posix complaint, and send it later (this week hopefully?).

One thing I should clarify, the problem is not exclusive to OSX (darwin) but basically all OSs that don't ship gnu coreutils or GNU xargs. So the fix would be (eq system-type 'linux) most likely. For example OpenBSD's xargs doesn't take -d nor its ls take --group-directories-first option.

Thanks for ivy btw

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jul 31, 2018

Thanks for ivy btw

You're welcome.

I'll look for a proper fix, posix complaint, and send it later (this week hopefully?).

Thanks in advance.

@PuercoWork

This comment has been minimized.

Copy link
Author

commented Jul 31, 2018

So looking into counsel it already has a posix compliant alternative in its codebase U_U'. But it is disabled by default. To make ivy-occur work for counsel-find-file one has to set counsel-find-file-occur-use-find to t. One way to handle this something like:

(defvar counsel-find-file-occur-use-find (when (eq system-type 'gnu/linux)
                                             t)
  "When non-nil, `counsel-find-file-occur' will use \"find\" as the base cmd.")

What do you think?

@abo-abo abo-abo closed this in 214664a Jul 31, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jul 31, 2018

Thanks for the pointer. I've set it to t on non-Linux systems. I still like to keep the xargs version if it's available, as the sorting is better there and the whole command is shorter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.