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

Improve find command for cd widgets: exclude proc/dev #122

Merged
merged 1 commit into from
Jan 25, 2015

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Jan 24, 2015

When using the widget in "/", it would descend into 'dev/'.
Using '*' for the starting path would do so also with the new '-fstype'
excludes.

The drawback / change now is that the './' prefix is being added, which
I don't mind. This could be fixed by throwing in some cut -b3- into
the pipe.

@junegunn
Copy link
Owner

Please ignore Travis failure. I momentarily gave up making it work.

@blueyed
Copy link
Contributor Author

blueyed commented Jan 24, 2015

Please ignore Travis failure

Heh.. :) - I was just wondering.

@blueyed
Copy link
Contributor Author

blueyed commented Jan 24, 2015

Feel free to squash-merge the commits, or tell me to rebase the PR.

@junegunn
Copy link
Owner

Doh, one thing I noticed is that find . includes . itself, so fzf gives an empty entry.

jg@mbp:~> find . | cut -b3- | head

.agignore
.ansible
.ansible/cp
.ansible/tmp
.ansible/tmp/ansible-1355468543.5-175586869495702
.ansible/tmp/ansible-1355468608.74-15792789855106
.ansible/tmp/ansible-1355468672.32-65045913254503
.ansible/tmp/ansible-1355468717.3-263255040481250
.ansible/tmp/ansible-1355468798.05-74592742241722

We could append grep -v ^$, but I wonder if there's a better way. Except for that, the change looks good to me. Could you fix the issue above and squash the commits into one?

@@ -369,14 +369,15 @@ function fzf_key_bindings
end

function __fzf_list
command find * -path '*/\.*' -prune \
command find -L ${1:-.} \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fish complains about this:

fish: Did you mean {$VARIABLE}? The '$' character begins a variable name. A bracket, which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.
Standard input:     command find -L ${1:-.} \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
                                    ^

Let's just change it to simple .

When using the widget in "/", it would descend into 'dev/'.
Using '*' for the starting path would do so also with the new '-fstype'
excludes.

`cut -b3-` and `sed 1d` have been added to massage the different format
of the list.

This also uses `-L` with all calls to find, especially for the file
finders.

Ref: junegunn#122
@blueyed
Copy link
Contributor Author

blueyed commented Jan 25, 2015

Fish should be fixed now, and I've added sed 1d to remove the first entry.

junegunn added a commit that referenced this pull request Jan 25, 2015
Improve `find` command for ALT-C: exclude proc/dev
@junegunn junegunn merged commit 47201c2 into junegunn:master Jan 25, 2015
@junegunn
Copy link
Owner

Merged. Thanks!

@blueyed blueyed deleted the improve-find-cdwidget branch January 25, 2015 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants