├── LICENSE ├── fzf.fish ├── fzf.lua ├── help └── fzf.md ├── readme.md └── repo.json /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Samantha Marshall 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of Samantha Marshall nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /fzf.fish: -------------------------------------------------------------------------------- 1 | function fzf 2 | set -l epoch (date "+%s") 3 | set -l file_path $TMPDIR/fzf-$epoch.result 4 | command fzf $argv >$file_path 5 | if test $status -eq 0 -a -s $file_path 6 | cat $file_path 7 | end 8 | if test -e $file_path 9 | rm $file_path 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /fzf.lua: -------------------------------------------------------------------------------- 1 | VERSION = "1.0.5" 2 | 3 | function fzf() 4 | if TermEmuSupported then 5 | local err = RunTermEmulator("fzf", false, true, "fzf.fzfOutput") 6 | if err ~= nil then 7 | messenger:Error(err) 8 | end 9 | else 10 | local output, err = RunInteractiveShell("fzf", false, true) 11 | if err ~= nil then 12 | messenger:Error(err) 13 | else 14 | fzfOutput(output) 15 | end 16 | end 17 | end 18 | 19 | function fzfOutput(output) 20 | local strings = import("strings") 21 | output = strings.TrimSpace(output) 22 | if output ~= "" then 23 | CurView():Open(output) 24 | end 25 | end 26 | 27 | MakeCommand("fzf", "fzf.fzf", 0) 28 | -------------------------------------------------------------------------------- /help/fzf.md: -------------------------------------------------------------------------------- 1 | # About the fzf plugin 2 | 3 | This plugin provides support for opening files via [fzf](https://github.com/junegunn/fzf). 4 | # Commands 5 | 6 | The plugin providies the following commands: 7 | 8 | * `fzf`: launch `fzf` to find a file to open. 9 | 10 | 11 | # Troubleshooting 12 | 13 | There is a [known issue](https://github.com/fish-shell/fish-shell/issues/1362) when using fzf with fish shell. To work around this, you should create a new fish shell function called `fzf` to be trigged instead of the `fzf` command directly. You can copy and past the following snippet into the file: 14 | 15 | $FISH_CONFIG_PATH/functions/fzf.fish 16 | 17 | ``` 18 | function fzf 19 | set -l epoch (date "+%s") 20 | set -l file_path $TMPDIR/fzf-$epoch.result 21 | command fzf $argv >$file_path 22 | if test $status -eq 0 -a -s $file_path 23 | cat $file_path 24 | end 25 | if test -e $file_path 26 | rm $file_path 27 | end 28 | end 29 | ``` 30 | 31 | 32 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # fzf plugin for micro 2 | 3 | This repository holds the [fzf](https://github.com/junegunn/fzf) plugin for [micro](https://github.com/zyedidia/micro) 4 | 5 | # Troubleshooting 6 | 7 | There is a [known issue](https://github.com/fish-shell/fish-shell/issues/1362) when using fzf with fish shell. To work around this, you should create a new fish shell function called `fzf` to be trigged instead of the `fzf` command directly. You can copy and past the following snippet into the file: 8 | 9 | $FISH_CONFIG_PATH/functions/fzf.fish 10 | 11 | ``` 12 | function fzf 13 | set -l epoch (date "+%s") 14 | set -l file_path $TMPDIR/fzf-$epoch.result 15 | command fzf $argv >$file_path 16 | if test $status -eq 0 -a -s $file_path 17 | cat $file_path 18 | end 19 | if test -e $file_path 20 | rm $file_path 21 | end 22 | end 23 | ``` 24 | -------------------------------------------------------------------------------- /repo.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Name": "fzf", 4 | "Description": "adds support to opening files via fzf", 5 | "Tags": ["fzf"], 6 | "Versions": [ 7 | { 8 | "Version": "1.0.5", 9 | "Url": "https://github.com/samdmarshall/micro-fzf-plugin/archive/v1.0.5.zip", 10 | "Require": { 11 | "micro": ">=1.1.2" 12 | } 13 | } 14 | ] 15 | } 16 | ] 17 | --------------------------------------------------------------------------------