Vim plugin that tracks your most recently and frequently used files while using the fzf.vim plugin.
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.
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
- fzf.vim
- bash
- awk
- GNU or MacOS
date
(supporting the%s
format option)
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.
g:fzf_filemru_bufwrite
- Update the MRU onBufWritePost
. 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
- Usegit ls-tree
to display repo files before other files that are found with the the finder command. Always enabled forProjectMru
. Default:0
g:fzf_filemru_ignore_submodule
- Ignore git submodule directories. Always enabled forProjectMru
. 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.
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.
--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
| Usegit 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.