Comments (6)
@suntong , does the already available -indexpath
option not meet this requirement for you?
from codesearch-pre-github.
Not quite, in the sense of usability. Consider the following:
csearch -name myproj2 regexp
and
csearch -indexpath /the/crazy/path/I/need/to/set/in/order/to/get/to/index/.myproj2 regexp
I think most people would agree that the first approach is more user friendly.
The -name
will only adding a small portion to $CSEARCHINDEX, not overriding it.
from codesearch-pre-github.
I wrote the response below but realized you are on windows so this doesn't work for you. But here it is anyway for unix folks.
I don't use the project model that a lot of people seem to use. There are two options that can solve your requirement easily.
- You can create a quick wrapper which will be even shorter which grabs names from a flat file. e.g. (untested)
% cat ~/.config/projects
myproj1=/the/crazy/path/I/need/to/set/in/order/to/get/to/index/.myproj2
theirproject2=/some/other/entirely/different/location/altogether
% cat csproj
#!/bin/sh
name="$1"
shift
source ~/.config/projects
csearch -indexpath "$name" "$@"
% csproj myproj2 regexp
- When working on specific projects I work in the directory of the project itself. I combine that with the following script which incrementally looks for the first index file in current or higher directories and uses that without needing to specify a path.
#!/usr/bin/env bash
findup() {
local what thisdir
what="$1"
[ -z "$what" ] && return 1
thisdir="$(pwd)" || return 1
cd "$thisdir" || return 1
thisdir="$(pwd)" || return 1
while [ -n "$thisdir" ]; do
if [ -e "$thisdir/$what" ] || [ -L "$thisdir/$what" ]; then
echo "$thisdir/$what"
return 0
fi
[ "$thisdir" = "/" ] && return 1
thisdir="$(/usr/bin/dirname "$thisdir")" || return 1
done
return 1
}
if [ -n "$GOPATH" ]; then
echo "$GOPATH" | sed -e 's/:/\
/g' | while read -r line ; do
eval "PATH=\"\$line/bin:\$PATH\""
done
else
GOPATH="$HOME/work/go"
PATH="$HOME/work/go/bin:$PATH"
fi
PATH="$HOME/bin:$PATH"
PATH=$PATH:$HOME/bin:$HOME/work/go/bin
export PATH
export GOPATH
[[ ! -e .csearchindex && ! -h .csearchindex ]] && echo ".csearchindex file is not present in current directory." >&2
deepest="$(findup .csearchindex)"
if [ -n "$deepest" ]; then
/usr/bin/env "CSEARCHINDEX=$deepest" csearch -f "$(pwd)" "$@"
else
csearch -f "$(pwd)" "$@"
fi
from codesearch-pre-github.
Thanks for the code.
Yeah I need codesearch on windows only. Under Linux I use glimpse, which "uses a very small index – in most cases 2-4% of the size of the text", and it is super easy to break into different indexes.
So again, on windows, since none of above is available, adding the feature to codesearch seems more desirable. I can do it myself, since the -name
will only adding a small portion to $CSEARCHINDEX -- the change will be very small and straightforward, but I'm wondering if you accept patches like this.
from codesearch-pre-github.
Patches are always welcome but when adding new options I need to evaluate many things. In this case, mainly:
- New options should not conflict with existing options.
- They should not lead to user experience bloat e.g. introduce multiple ways of doing the same thing.
- They should not lead to unnecessary code complexity.
- They should try to be consistent with existing tools out there.
- They should be implemented to not diverge too much from the original codesearch project. (Yes, I still dream it will come alive someday somehow despite years of indication otherwise :) )
- Maybe do both or pick between this and #9 in one shot.
Unfortunately, my time is limited due to a busy day job so not sure when I can participate more than casually in such discussions/development. But it's open source so you can modify it as you please even if I can't find time. Using the Makefile you can do cross platform builds and get Windows binaries easily.
from codesearch-pre-github.
This issue was moved to junkblocker/codesearch#5
from codesearch-pre-github.
Related Issues (7)
- index: merge of index fails HOT 1
- How to use codesearch HOT 1
- Windows + any source. HOT 22
- Highlight matches HOT 1
- Incremental indexing HOT 3
- Exclude path for csearch HOT 1
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 codesearch-pre-github.