Giter Site home page Giter Site logo

Comments (6)

junkblocker avatar junkblocker commented on May 19, 2024

@suntong , does the already available -indexpath option not meet this requirement for you?

from codesearch-pre-github.

suntong avatar suntong commented on May 19, 2024

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.

junkblocker avatar junkblocker commented on May 19, 2024

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.

  1. 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
  1. 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.

suntong avatar suntong commented on May 19, 2024

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.

junkblocker avatar junkblocker commented on May 19, 2024

Patches are always welcome but when adding new options I need to evaluate many things. In this case, mainly:

  1. New options should not conflict with existing options.
  2. They should not lead to user experience bloat e.g. introduce multiple ways of doing the same thing.
  3. They should not lead to unnecessary code complexity.
  4. They should try to be consistent with existing tools out there.
  5. 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 :) )
  6. 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.

junkblocker avatar junkblocker commented on May 19, 2024

This issue was moved to junkblocker/codesearch#5

from codesearch-pre-github.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.