Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hay-kot committed Aug 2, 2022
1 parent 251fe39 commit fbc182e
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Gofind

GoFind is a tiny and poorly written tool that I use to quickly search through my file system to quickly navigate between repositories or any directory that has a specific child. It uses the `filepath.Match` function to look for matching children in root directories, and if the child is found, it will stop return the parent directory and stop recursively looking into that parents children.
GoFind is a small cli program for quickly finding and searching directories using the producer/consumer pattern. It uses the `filepath.Match` function to look for matching children in root directories, and if the child is found, it will stop return the parent directory and stop recursively looking into that parents children.

Once a match is found it's then piped to `fzf` to allow the user to select a directory and then it's spit out to the terminal which can then be used to change into that director or open it in vscode or whatever. **IMPORTANT** fzf must be installed and in the path for this to work, additionally the way I'm piping the output to fzf is probably not good practice and will likely not work on other machines YMMV.
**Why though?** The primary use case for this library is to tie into other scripts to quickly and easily navigate (or other action) to a file path. For example you can use an alias to quickly search through all your git repositories and quickly search, find, and navigate in your terminal. See the [examples](#examples) for more details

## Config
GoFind uses a json file in `~/.config/gofind.json` to store the configuration for the search entries and the default search. It also uses this file to cache results so that the search is faster on subsequent runs. The config file example here has two jobs,

**repos:** which will recursively search the ~/Code directory for any directory that matches `.git`
**compose:** which will recursively search the ~/Docker directory for any directory that matches `docker-compose*`
**compose:** which will recursively search the ~/Docker directory for any directory that matches `docker-compose*`

I use these to either quickly find a repository I forgot the name of or where it exists, or quickly find a docker stack location and navigate to it.

Expand All @@ -17,11 +17,11 @@ I use these to either quickly find a repository I forgot the name of or where it
"default": "repos",
"commands": {
"compose": {
"root": "~/Docker",
"root": ["~/Docker"],
"match": "docker-compose*"
},
"repos": {
"root": "~/Code",
"root": ["~/Code"],
"match": ".git"
}
},
Expand All @@ -36,12 +36,41 @@ NAME:
gofind - an interactive search for directories using the filepath.Match function

USAGE:
gofind [config-entry string] e.g. `gofind repos`
gofind [global options] command [command options] [arguments...]

VERSION:
0.1.0

COMMANDS:
cache, c cache all config entries
help, h Shows a list of commands or help for one command
cache, c cache all config entries
find, f run interactive finder for entry
setup first time setup
config, c add, remove, or list configuration entries
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--help, -h show help (default: false)
--help, -h show help (default: false)
--version, -v print the version (default: false)
```

## Examples


**Open VSCode**

```shell
alias fcode="code \`gofind repos\`"
```

**Change into Directory**

```shell
repos() {
# Navigate to repos director and open target directory is specified
if [ -z "$1" ]; then
cd `gofind repos`
return
fi
cd ~/code/repos/$1
}
```

0 comments on commit fbc182e

Please sign in to comment.