Giter Club home page Giter Club logo

fzf-filemru's Introduction

FZF File MRU

Vim plugin that tracks your most recently and frequently used files while using the fzf.vim plugin.

Sweet FZF MRU GIF

This plugin provides the FilesMru and ProjectMru commands, which are basically a pass-throughs to the Files command. So, all you really need to do is use FilesMru instead of Files.

When using FilesMru or ProjectMru, FZF will display files like usual, except your most recently used files (matching the working directory) will appear before all other files.

ProjectMru does the same thing as FilesMru except that it uses git ls-tree to display files after MRU files (and before other found files), and ignores repository submodule directories.

UpdateMru is a utility command that allows you to manually update the MRU.

MRU files are tracked in $XDG_CACHE_HOME/fzf_filemru. A timestamp (rounded to 2 minute intervals) and selection count is used to determine recency and frequency.

Example Usage

nnoremap <c-p> :FilesMru --tiebreak=end<cr>

The MRU list is updated when a file is saved or selected from the FZF menu. Though not recommended, you could update the MRU list when a file is opened by other means with the following script:

augroup custom_filemru
  autocmd!
  autocmd BufWinEnter * UpdateMru
augroup END

Requirements

  • fzf.vim
  • bash
  • awk
  • GNU or MacOS date (supporting the %s format option)

Command Usage

The commands ignore the original directory argument and instead takes flags that are passed FZF. Run fzf --help to see what flags you can pass. A decent flag to use is --tiebreak=index which uses the initial order of the listed file as a secondary sort. --tiebreak=end will do a better job of sorting filename matches first.

Options

  • g:fzf_filemru_bufwrite - Update the MRU on BufWritePost. This can be useful if you want your most saved files to appear near the top of the results. Default: 0
  • g:fzf_filemru_git_ls - Use git ls-tree to display repo files before other files that are found with the the finder command. Always enabled for ProjectMru. Default: 0
  • g:fzf_filemru_ignore_submodule - Ignore git submodule directories. Always enabled for ProjectMru. Default: 0
  • g:fzf_filemru_colors - Colors for file prefixes. Uses the xterm 256 color palette. Default: {'mru': 6, 'git': 3}.

Note: Even if git submodule files are ignored, they can still appear in the MRU.

Command Line

You can use bin/filemru.sh directly from the command line. It will act as fzf for finding files, but will update the MRU with your file selections. This is currently not useful in the shell on its own.

Command Line Switches

  • --exclude - Exclude a file from MRU output. Must be relative to the current directory.
  • --files | Just find files with MRU files displayed first and exit.
  • --update | Updates the MRU with the files specified after this switch. The files must be relative to the current directory.
  • --git | Use git ls-tree to display repo files after MRU files, but before other found files.
  • --ignore-submodules | Ignore git submodule directories.
  • --mru-color | Color for the MRU prefix.
  • --git-color | Color for the Git prefix.

fzf-filemru's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fzf-filemru's Issues

How to pass arguments to underlying fzf?

Is there a way to customize fzf using the various suggestions on their wiki?

For example, I like this preview option which looks great, but it doesn't appear with your plugin:

command! -bang -nargs=? -complete=dir Files
  \ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)

How to display a cleaner file list

(love this plugin!)

Is there a way to clean up the MRU list? Right now it displays MRU files with a somewhat nonsensical path. e.g. in this project I've only accessed index.js:
screen shot 2017-03-20 at 12 31 58 pm

Ability to update mru list when entering a buffer

I'm not actually sure about whether this is a good idea or not, but I was thinking that we never a buffer is entered and/or created (that has a filename), they MRU list should be updated so the current file we will be at the start of the list.

The reason for this is that I may not open a file using fzf. For example I may open a file using nerd tree, which I would not be considering when a close the file and realise I want to reopen it. When a close one of them, I want to be able to use fzf mru to reopen it.

Another reason to consider is that I may open Vim from a session, which opens many files at once, neither of them from fzf. When a close one of them, just like the above, I want to be able to use fzf mru to reopen it.

What do other people think of this idea?

Q: Is there a way to always have the `mru` entries ordered to the bottom?

First of all, I really love this plugin! It was exactly what I was missing before, when working on large projects. So thanks for that!

As for my question, when I start :FilesMru all entries are nicely sorted so that the mru entries are all at the bottom. But if there are a lot of mru files and you try to filter the list by typing in a few characters it looks like the ordering of fzf takes over and ignores mru entries.

So now the mru entries are scattered all over the place. It would be really nice if they would alway be ordered at the bottom, even when being filtered.

Breaking on MacOS

Hi,

I use this plugin on both MacOS and Linux. I've noticed that sometimes on MacOS it breaks as seen on the image below. I've never gotten this on Linux.

screen shot 2018-10-15 at 22 11 45

I wonder if this is perhaps some misconfiguration or if is there something I can do to fix?

Thanks

Only show MRU files

Currently when I run :FilesMru it displays 3 mru files at the bottom ๐Ÿ‘ then above all other files. If I start typing it will search through the entire list. Is there a way to either only show mru files or to first search in the mru files ?

Thanks :)

Only current directory files shown

I want all mru files to be listed, not only the ones pertaining to current directory.
Ofcourse as always non-mru files should be restricted to current directory only.
How can I achieve that.

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.