-
-
Save mitchellh/ee14d6ecb9196a07da56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"------------------------------------------------------------ | |
" CtrlP | |
"------------------------------------------------------------ | |
" Set the max files | |
let g:ctrlp_max_files = 10000 | |
" Optimize file searching | |
if has("unix") | |
let g:ctrlp_user_command = { | |
\ 'types': { | |
\ 1: ['.git/', 'cd %s && git ls-files'] | |
\ }, | |
\ 'fallback': 'find %s -type f | head -' . g:ctrlp_max_files | |
\ } | |
endif |
You can probably make this a step better by caching the output of find
, like:
FILELIST=filelist
if [[ ! =f $FILELIST ]]; then find . -type f > $FILELIST; fi
cat $FILELIST
Or something along those lines. I'm copying, more or less, code from build/envsetup.sh#godir() from Google's Android source, which is somewhat convenient in traversing 30000+ files:
function godir () {
if [[ -z "$1" ]]; then
echo "Usage: godir <regex>"
return
fi
T=$(gettop)
if [[ ! -f $T/filelist ]]; then
echo -n "Creating index..."
(cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
echo " Done"
echo ""
fi
local lines
lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
if [[ ${#lines[@]} = 0 ]]; then
echo "Not found"
return
fi
local pathname
local choice
if [[ ${#lines[@]} > 1 ]]; then
while [[ -z "$pathname" ]]; do
local index=1
local line
for line in ${lines[@]}; do
printf "%6s %s\n" "[$index]" $line
index=$(($index + 1))
done
echo
echo -n "Select one: "
unset choice
read choice
if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
echo "Invalid choice"
continue
fi
pathname=${lines[$(($choice-1))]}
done
else
pathname=${lines[0]}
fi
cd $T/$pathname
}
@shurane Actually CtrlP handles caching for you! :)
@shurane The uncached version kills the find process after reading "g:ctrlp_max_files" lines; The cached version writes all results.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JFTR, the Mercurial equivalent of
git ls-files
would behg manifest
– works like a charm too.