Comments (6)
derp, may I ask what ${1:-*}
is doing actually? I can't figure out how to get it to include hidden files the current directory. Is it a subshell? A glob? An awk expression? I'm having a hard time googling it. Thanks very much.
from fzf.
Hi, thanks for your interest in fzf.
If
foo
is a directory in the current directory, tryfzf -x
with the following inputs
Without stdin pipe, fzf command will use find command to populate the list of files and symlinks under the current directory, excluding hidden files and directories. (The actual command can be seen here: https://github.com/junegunn/fzf/blob/master/fzf#L496) The list will not contain the names of the subdirectories.
^foo
returns all results starting with foo, including the foo directory
Therefore, this is not something we can expect, you shouldn't be able to match foo
directory itself. Could you check again?
Try
find ${1:-*} 2> /dev/null | fzf -x
^foo$ returns nothing
You're right, currently fzf will look for items that start with foo$
, I'll fix this behavior.
derp, may I ask what
${1:-*}
is doing actually?
$1
is the first argument to the function, and ${1:-*}
evaluates to *
if the argument is empty (or not given)
Take the following example:
do_fzf() {
find ${1:-*} 2> /dev/null | fzf -x
}
do_fzf
evaluates tofind * 2> /dev/null | fzf -x
do_fzf .
find . 2> /dev/null | fzf -x
The difference is that *
will not match hidden files and directories that are direct children of the current directory. Usually I work in the root directory of a git repository, so *
is a concise way to ignore .git
directory. (The command in https://github.com/junegunn/fzf/blob/master/fzf#L496 is the correct way to ignore all the hidden files, but a bit lengthy)
Hmm, it seems there is a confusing example on the README page, I'll update the documentation as well.
from fzf.
^xxx$
has been fixed. Thanks for the report :)
I can't figure out how to get it to include hidden files the current directory.
- All the files and directories (and symlinks):
find .
- Exclude .git directories:
find . -name .git -prune -o -print
- Only directories (excluding .git):
find . -name .git -prune -o -type d -print
So basically, you don't need ${1:-*}
or ${1:-.}
if you're only interested in the current directory.
I wrote ${1:-*}
in the examples to allow something like fd ~/github
in addition to simple fd
from fzf.
you shouldn't be able to match
foo
directory itself. Could you check again?
Maybe I wasn't clear: foo is in the current directory. It is not itself the current directory.
${1:-*}
evaluates to*
Thanks, I should have realized that since it is inside a function definition 😴
All the files and directories (and symlinks):
find .
Yeah, the readme example got me and I wasn't thinking carefully. Thanks! Here's what I'm using now:
if [ -f ~/.fzf.bash ]; then
source ~/.fzf.bash
f() { # fzf / includes hidden directories
find . -name .git -prune -o $1 -print 2> /dev/null | sed 's@^..\(.*\)$@\1@' | fzf -x
}
fd() { # fzf / change to directory
cd $(f "-type d")
}
fi
f()
fuzzy-searches everything except .git
, and it trims the initial ./
prepended by find .
, so the output is formatted nicer (which makes searching with fzf -x
nicer).
from fzf.
Hey, thanks for the feedback!
Maybe I wasn't clear: foo is in the current directory. It is not itself the current directory.
No I don't think there was a misunderstanding. The default find command does not print directories:
find * -path '*/\\.*' -prune -o -type f -print -o -type l -print
As you can see, it only prints regular files and symlinks. Try
mkdir /tmp/fzf-test
cd /tmp/fzf-test
mkdir directory
touch file
ln -s directory symlink
fzf -x
and you'll see that directory
is not in the list.
So I couldn't understand how you could match foo
directory in the first place.
Regarding your bash functions, I think sed 's@^..\(.*\)$@\1@'
can be written concisely as sed s/..//
😃
from fzf.
The default find command does not print directories:
find * -path '/.' -prune -o -type f -print -o -type l -print
I see, you mean the default fzf
find call. I thought you mean plain old find
. I guess my original report was wrong in that regard.
sed 's@^..(.*)$@\1@' can be written concisely as sed s/..//
Much better, thanks!
from fzf.
Related Issues (20)
- Commit 83b60339 broke use of pbogut/fzf-mru.vim plugin HOT 6
- arrow up keybinding is showing no scrollable list HOT 11
- unknown option --no-tmux error HOT 1
- consider adding `--head` option? HOT 1
- Security Alert: Potential Trojan Detected in Windows Release v0.54.1 HOT 5
- [Feature Request] Line numbers for selectable results HOT 4
- Fzf 0.54.1 mac arm64 release contains a `._fzf` file HOT 3
- Using `FZF_POS` has a high impact on performance HOT 6
- Change tagline
- Request: Add a match whole word option HOT 3
- FZF + interactive RipGrep deadlock HOT 5
- Fzf window not showing in process substitution using zsh HOT 1
- `fzf --tmux bottom` opens tmux popup on the top HOT 5
- Impossible to get "sudo su" to be prioritized HOT 4
- Wrong list scrolling with --read0 and --height HOT 2
- Help creating custom fuzzy seach command script. HOT 1
- [Feature Request] Handle pytest command the same as python HOT 9
- Requires tmux 3.2 or above not only popup window HOT 1
- Support comments within FZF_DEFAULT_OPTS_FILE content HOT 2
- Matching with word boundaries HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fzf.