Giter Club home page Giter Club logo

fscache's Introduction

FS Cache

fscache monitors files on your computer and allows you to quickly gather lists of them. Combined with fzf or ctrlp to get amazing mobility of your computer.

It works, but is rough around the edges.

Why

CtrlP is amazing for jumping around a repo, but it really struggles with listing all the files to fuzzy search from. For a long time I had a bit of code in my ctrlp config that essentially boiled down to:

[ cwd -e $HOME ] && "echo can't run ctrlp from home".

This worked, and prevented me from locking up my VIM every time I had the misfortune of invoking it from the home directory. Combine this with git ls-files and I had a working solution.

That was until I started working in a monorepo with around 50k files. Even with git ls-files CtrlP was struggling. Enabling caching made it manageable but I was constantly struggling with the cache being out of date.

So fscache was born. Something that would monitor and maintain a cache. Then provide some tools for reading from it and quickly filtering it down to relevant data. This made working in the monorepo quick, and allowed me to hop around from my home directory.

Subcommands

global flags

flag default description
-debug false Enable debug logging
-log-level "error" Set the log level
-socket ~/.cache/fscache.socket Communication socket location

run

Run starts the fscache server.

flag default description
-r / -root ~/ Where to start monitoring from
mode pebble Which backend database to use

read

Read fetches data from the server for use with another tool.

flag default description
-p / -prefix "" Limit returned items to subpath
-r false Auto discover git root and set prefix
-n all Number of items to return. 0 for all
-b 1000 Number of items to return per batch
-d false Only return directories
-f false Only return files

stop

Stop either shuts the server down or restarts it.

flag default description
-r / -restart false restart instead of stopping

Integrations

CtrlP & VIM

fscache can be used with VIM and CtrlP by using something like the following setting.

let g:ctrlp_user_command = {
  \   'types': {
  \     1: ['.git', 'fscache read -p %s']
  \   },
  \   'fallback': 'fscache read'
  \ }

FZF-VIM

To integrate with fzf-vim simply add the following to your vimrc.

let $FZF_DEFAULT_COMMAND='fscache read -r'

FZF

fscache can be paired with FZF to make a nice and easy command for jumping around your computer.

function fzd() {
  local refresh="fscache read -d"

  if [ "$1" != "" ]; then
    local initial_query="-q $1"
  fi

  local dir=$(eval $refresh | fzf \
    --filepath-word \
    --bind='ctrl-t:next-history'\
    --bind='ctrl-r:previous-history'\
    --bind='ctrl-n:down' \
    --bind='ctrl-p:up' \
    --layout='reverse-list' \
    --tiebreak=length \
    --bind='change:first' \
    --header='Press F5 to reload' \
    --bind="f5:reload(${refresh})" \
    --history=$FZD_HISTORY $initial_query)

  if [ "$dir" != "" ];
  then
    pushd -q $dir
  fi
}

fscache's People

Contributors

keyneston avatar

Watchers

 avatar

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.