mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-16 12:43:50 -07:00
Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
dba14d2630 | ||
|
2986e64a49 | ||
|
1d8bd11b67 | ||
|
bafb99d520 | ||
|
3cc8a74a91 | ||
|
c0aa5a438f | ||
|
825d401403 | ||
|
9dfca77c36 | ||
|
82c4af2902 | ||
|
736344e151 | ||
|
6f9663da62 | ||
|
f8ae1786dd | ||
|
c60ed17583 | ||
|
e0f0b5bcf9 | ||
|
9e96073128 | ||
|
0db65c22d3 | ||
|
d785135606 | ||
|
ae15eda546 | ||
|
f2d44ab5a7 | ||
|
43798fc2e8 | ||
|
9dc4b40d7a | ||
|
1cb19dbf65 | ||
|
1ab4289ad6 |
24
CHANGELOG.md
24
CHANGELOG.md
@@ -1,6 +1,30 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.23.0
|
||||||
|
------
|
||||||
|
- Support preview scroll offset relative to window height
|
||||||
|
```sh
|
||||||
|
git grep --line-number '' |
|
||||||
|
fzf --delimiter : \
|
||||||
|
--preview 'bat --style=numbers --color=always --highlight-line {2} {1}' \
|
||||||
|
--preview-window +{2}-/2
|
||||||
|
```
|
||||||
|
- Added `--preview-window` option for sharp edges (`--preview-window sharp`)
|
||||||
|
- Added `--preview-window` option for cyclic scrolling (`--preview-window cycle`)
|
||||||
|
- Reduced vertical padding around the preview window when `--preview-window
|
||||||
|
noborder` is used
|
||||||
|
- Added actions for preview window
|
||||||
|
- `preview-half-page-up`
|
||||||
|
- `preview-half-page-down`
|
||||||
|
- Vim
|
||||||
|
- Popup width and height can be given in absolute integer values
|
||||||
|
- Added `fzf#exec()` function for getting the path of fzf executable
|
||||||
|
- It also downloads the latest binary if it's not available by running
|
||||||
|
`./install --bin`
|
||||||
|
- Built with Go 1.15.2
|
||||||
|
- We no longer provide 32-bit binaries
|
||||||
|
|
||||||
0.22.0
|
0.22.0
|
||||||
------
|
------
|
||||||
- Added more options for `--bind`
|
- Added more options for `--bind`
|
||||||
|
18
Makefile
18
Makefile
@@ -8,7 +8,6 @@ SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(MAKEFILE)
|
|||||||
REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES))
|
REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES))
|
||||||
BUILD_FLAGS := -a -ldflags "-X main.revision=$(REVISION) -w '-extldflags=$(LDFLAGS)'" -tags "$(TAGS)"
|
BUILD_FLAGS := -a -ldflags "-X main.revision=$(REVISION) -w '-extldflags=$(LDFLAGS)'" -tags "$(TAGS)"
|
||||||
|
|
||||||
BINARY32 := fzf-$(GOOS)_386
|
|
||||||
BINARY64 := fzf-$(GOOS)_amd64
|
BINARY64 := fzf-$(GOOS)_amd64
|
||||||
BINARYARM5 := fzf-$(GOOS)_arm5
|
BINARYARM5 := fzf-$(GOOS)_arm5
|
||||||
BINARYARM6 := fzf-$(GOOS)_arm6
|
BINARYARM6 := fzf-$(GOOS)_arm6
|
||||||
@@ -16,7 +15,6 @@ BINARYARM7 := fzf-$(GOOS)_arm7
|
|||||||
BINARYARM8 := fzf-$(GOOS)_arm8
|
BINARYARM8 := fzf-$(GOOS)_arm8
|
||||||
BINARYPPC64LE := fzf-$(GOOS)_ppc64le
|
BINARYPPC64LE := fzf-$(GOOS)_ppc64le
|
||||||
VERSION := $(shell awk -F= '/version =/ {print $$2}' src/constants.go | tr -d "\" ")
|
VERSION := $(shell awk -F= '/version =/ {print $$2}' src/constants.go | tr -d "\" ")
|
||||||
RELEASE32 := fzf-$(VERSION)-$(GOOS)_386
|
|
||||||
RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd64
|
RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd64
|
||||||
RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm5
|
RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm5
|
||||||
RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm6
|
RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm6
|
||||||
@@ -30,10 +28,6 @@ ifeq ($(UNAME_M),x86_64)
|
|||||||
BINARY := $(BINARY64)
|
BINARY := $(BINARY64)
|
||||||
else ifeq ($(UNAME_M),amd64)
|
else ifeq ($(UNAME_M),amd64)
|
||||||
BINARY := $(BINARY64)
|
BINARY := $(BINARY64)
|
||||||
else ifeq ($(UNAME_M),i686)
|
|
||||||
BINARY := $(BINARY32)
|
|
||||||
else ifeq ($(UNAME_M),i386)
|
|
||||||
BINARY := $(BINARY32)
|
|
||||||
else ifeq ($(UNAME_M),armv5l)
|
else ifeq ($(UNAME_M),armv5l)
|
||||||
BINARY := $(BINARYARM5)
|
BINARY := $(BINARYARM5)
|
||||||
else ifeq ($(UNAME_M),armv6l)
|
else ifeq ($(UNAME_M),armv6l)
|
||||||
@@ -56,13 +50,11 @@ target:
|
|||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
ifeq ($(GOOS),windows)
|
ifeq ($(GOOS),windows)
|
||||||
release: target/$(BINARY32) target/$(BINARY64)
|
release: target/$(BINARY64)
|
||||||
cd target && cp -f $(BINARY32) fzf.exe && zip $(RELEASE32).zip fzf.exe
|
|
||||||
cd target && cp -f $(BINARY64) fzf.exe && zip $(RELEASE64).zip fzf.exe
|
cd target && cp -f $(BINARY64) fzf.exe && zip $(RELEASE64).zip fzf.exe
|
||||||
cd target && rm -f fzf.exe
|
cd target && rm -f fzf.exe
|
||||||
else ifeq ($(GOOS),linux)
|
else ifeq ($(GOOS),linux)
|
||||||
release: target/$(BINARY32) target/$(BINARY64) target/$(BINARYARM5) target/$(BINARYARM6) target/$(BINARYARM7) target/$(BINARYARM8) target/$(BINARYPPC64LE)
|
release: target/$(BINARY64) target/$(BINARYARM5) target/$(BINARYARM6) target/$(BINARYARM7) target/$(BINARYARM8) target/$(BINARYPPC64LE)
|
||||||
cd target && cp -f $(BINARY32) fzf && tar -czf $(RELEASE32).tgz fzf
|
|
||||||
cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf
|
cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf
|
||||||
cd target && cp -f $(BINARYARM5) fzf && tar -czf $(RELEASEARM5).tgz fzf
|
cd target && cp -f $(BINARYARM5) fzf && tar -czf $(RELEASEARM5).tgz fzf
|
||||||
cd target && cp -f $(BINARYARM6) fzf && tar -czf $(RELEASEARM6).tgz fzf
|
cd target && cp -f $(BINARYARM6) fzf && tar -czf $(RELEASEARM6).tgz fzf
|
||||||
@@ -71,8 +63,7 @@ release: target/$(BINARY32) target/$(BINARY64) target/$(BINARYARM5) target/$(BIN
|
|||||||
cd target && cp -f $(BINARYPPC64LE) fzf && tar -czf $(RELEASEPPC64LE).tgz fzf
|
cd target && cp -f $(BINARYPPC64LE) fzf && tar -czf $(RELEASEPPC64LE).tgz fzf
|
||||||
cd target && rm -f fzf
|
cd target && rm -f fzf
|
||||||
else
|
else
|
||||||
release: target/$(BINARY32) target/$(BINARY64)
|
release: target/$(BINARY64)
|
||||||
cd target && cp -f $(BINARY32) fzf && tar -czf $(RELEASE32).tgz fzf
|
|
||||||
cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf
|
cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf
|
||||||
cd target && rm -f fzf
|
cd target && rm -f fzf
|
||||||
endif
|
endif
|
||||||
@@ -96,9 +87,6 @@ install: bin/fzf
|
|||||||
clean:
|
clean:
|
||||||
$(RM) -r target
|
$(RM) -r target
|
||||||
|
|
||||||
target/$(BINARY32): $(SOURCES)
|
|
||||||
GOARCH=386 $(GO) build $(BUILD_FLAGS) -o $@
|
|
||||||
|
|
||||||
target/$(BINARY64): $(SOURCES)
|
target/$(BINARY64): $(SOURCES)
|
||||||
GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@
|
GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@
|
||||||
|
|
||||||
|
@@ -127,8 +127,9 @@ let g:fzf_action = {
|
|||||||
\ 'ctrl-v': 'vsplit' }
|
\ 'ctrl-v': 'vsplit' }
|
||||||
|
|
||||||
" Default fzf layout
|
" Default fzf layout
|
||||||
" - down / up / left / right
|
" - down / up / left / right / window
|
||||||
let g:fzf_layout = { 'down': '40%' }
|
let g:fzf_layout = { 'down': '40%' }
|
||||||
|
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
|
||||||
|
|
||||||
" You can set up fzf window using a Vim command (Neovim or latest Vim 8 required)
|
" You can set up fzf window using a Vim command (Neovim or latest Vim 8 required)
|
||||||
let g:fzf_layout = { 'window': 'enew' }
|
let g:fzf_layout = { 'window': 'enew' }
|
||||||
@@ -290,8 +291,8 @@ When `window` entry is a dictionary, fzf will start in a popup window. The
|
|||||||
following options are allowed:
|
following options are allowed:
|
||||||
|
|
||||||
- Required:
|
- Required:
|
||||||
- `width` [float range [0 ~ 1]]
|
- `width` [float range [0 ~ 1]] or [integer range [8 ~ ]]
|
||||||
- `height` [float range [0 ~ 1]]
|
- `height` [float range [0 ~ 1]] or [integer range [4 ~ ]]
|
||||||
- Optional:
|
- Optional:
|
||||||
- `yoffset` [float default 0.5 range [0 ~ 1]]
|
- `yoffset` [float default 0.5 range [0 ~ 1]]
|
||||||
- `xoffset` [float default 0.5 range [0 ~ 1]]
|
- `xoffset` [float default 0.5 range [0 ~ 1]]
|
||||||
@@ -386,8 +387,8 @@ The latest versions of Vim and Neovim include builtin terminal emulator
|
|||||||
|
|
||||||
```vim
|
```vim
|
||||||
" Required:
|
" Required:
|
||||||
" - width [float range [0 ~ 1]]
|
" - width [float range [0 ~ 1]] or [integer range [8 ~ ]]
|
||||||
" - height [float range [0 ~ 1]]
|
" - height [float range [0 ~ 1]] or [integer range [4 ~ ]]
|
||||||
"
|
"
|
||||||
" Optional:
|
" Optional:
|
||||||
" - xoffset [float default 0.5 range [0 ~ 1]]
|
" - xoffset [float default 0.5 range [0 ~ 1]]
|
||||||
@@ -416,8 +417,8 @@ When fzf starts in a terminal buffer, the file type of the buffer is set to
|
|||||||
`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of
|
`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of
|
||||||
the window.
|
the window.
|
||||||
|
|
||||||
For example, if you use the default layout (`{'down': '40%'}`) on Neovim, you
|
For example, if you use a non-popup layout (e.g. `{'down': '40%'}`) on Neovim,
|
||||||
might want to temporarily disable the statusline for a cleaner look.
|
you might want to temporarily disable the statusline for a cleaner look.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
if has('nvim') && !exists('g:fzf_layout')
|
if has('nvim') && !exists('g:fzf_layout')
|
||||||
|
60
README.md
60
README.md
@@ -22,6 +22,8 @@ Pros
|
|||||||
Table of Contents
|
Table of Contents
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
<!-- vim-markdown-toc GFM -->
|
||||||
|
|
||||||
* [Installation](#installation)
|
* [Installation](#installation)
|
||||||
* [Using Homebrew or Linuxbrew](#using-homebrew-or-linuxbrew)
|
* [Using Homebrew or Linuxbrew](#using-homebrew-or-linuxbrew)
|
||||||
* [Using git](#using-git)
|
* [Using git](#using-git)
|
||||||
@@ -38,8 +40,8 @@ Table of Contents
|
|||||||
* [Options](#options)
|
* [Options](#options)
|
||||||
* [Demo](#demo)
|
* [Demo](#demo)
|
||||||
* [Examples](#examples)
|
* [Examples](#examples)
|
||||||
* [fzf-tmux script](#fzf-tmux-script)
|
* [`fzf-tmux` script](#fzf-tmux-script)
|
||||||
* [Key bindings for command line](#key-bindings-for-command-line)
|
* [Key bindings for command-line](#key-bindings-for-command-line)
|
||||||
* [Fuzzy completion for bash and zsh](#fuzzy-completion-for-bash-and-zsh)
|
* [Fuzzy completion for bash and zsh](#fuzzy-completion-for-bash-and-zsh)
|
||||||
* [Files and directories](#files-and-directories)
|
* [Files and directories](#files-and-directories)
|
||||||
* [Process IDs](#process-ids)
|
* [Process IDs](#process-ids)
|
||||||
@@ -52,12 +54,18 @@ Table of Contents
|
|||||||
* [Advanced topics](#advanced-topics)
|
* [Advanced topics](#advanced-topics)
|
||||||
* [Performance](#performance)
|
* [Performance](#performance)
|
||||||
* [Executing external programs](#executing-external-programs)
|
* [Executing external programs](#executing-external-programs)
|
||||||
|
* [Reloading the candidate list](#reloading-the-candidate-list)
|
||||||
|
* [1. Update the list of processes by pressing CTRL-R](#1-update-the-list-of-processes-by-pressing-ctrl-r)
|
||||||
|
* [2. Switch between sources by pressing CTRL-D or CTRL-F](#2-switch-between-sources-by-pressing-ctrl-d-or-ctrl-f)
|
||||||
|
* [3. Interactive ripgrep integration](#3-interactive-ripgrep-integration)
|
||||||
* [Preview window](#preview-window)
|
* [Preview window](#preview-window)
|
||||||
* [Tips](#tips)
|
* [Tips](#tips)
|
||||||
* [Respecting .gitignore](#respecting-gitignore)
|
* [Respecting `.gitignore`](#respecting-gitignore)
|
||||||
* [Fish shell](#fish-shell)
|
* [Fish shell](#fish-shell)
|
||||||
* [Related projects](#related-projects)
|
* [Related projects](#related-projects)
|
||||||
* [<a href="LICENSE">License</a>](#license)
|
* [License](#license)
|
||||||
|
|
||||||
|
<!-- vim-markdown-toc -->
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
@@ -528,6 +536,50 @@ fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort
|
|||||||
|
|
||||||
See *KEY BINDINGS* section of the man page for details.
|
See *KEY BINDINGS* section of the man page for details.
|
||||||
|
|
||||||
|
### Reloading the candidate list
|
||||||
|
|
||||||
|
By binding `reload` action to a key or an event, you can make fzf dynamically
|
||||||
|
reload the candidate list. See https://github.com/junegunn/fzf/issues/1750 for
|
||||||
|
more details.
|
||||||
|
|
||||||
|
#### 1. Update the list of processes by pressing CTRL-R
|
||||||
|
|
||||||
|
```sh
|
||||||
|
FZF_DEFAULT_COMMAND='ps -ef' \
|
||||||
|
fzf --bind 'ctrl-r:reload($FZF_DEFAULT_COMMAND)' \
|
||||||
|
--header 'Press CTRL-R to reload' --header-lines=1 \
|
||||||
|
--height=50% --layout=reverse
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Switch between sources by pressing CTRL-D or CTRL-F
|
||||||
|
|
||||||
|
```sh
|
||||||
|
FZF_DEFAULT_COMMAND='find . -type f' \
|
||||||
|
fzf --bind 'ctrl-d:reload(find . -type d),ctrl-f:reload($FZF_DEFAULT_COMMAND)' \
|
||||||
|
--height=50% --layout=reverse
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Interactive ripgrep integration
|
||||||
|
|
||||||
|
The following example uses fzf as the selector interface for ripgrep. We bound
|
||||||
|
`reload` action to `change` event, so every time you type on fzf, ripgrep
|
||||||
|
process will restart with the updated query string denoted by the placeholder
|
||||||
|
expression `{q}`. Also, note that we used `--phony` option so that fzf doesn't
|
||||||
|
perform any secondary filtering.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
INITIAL_QUERY=""
|
||||||
|
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
|
||||||
|
FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
|
||||||
|
fzf --bind "change:reload:$RG_PREFIX {q} || true" \
|
||||||
|
--ansi --phony --query "$INITIAL_QUERY" \
|
||||||
|
--height=50% --layout=reverse
|
||||||
|
```
|
||||||
|
|
||||||
|
If ripgrep doesn't find any matches, it will exit with a non-zero exit status,
|
||||||
|
and fzf will warn you about it. To suppress the warning message, we added
|
||||||
|
`|| true` to the command, so that it always exits with 0.
|
||||||
|
|
||||||
### Preview window
|
### Preview window
|
||||||
|
|
||||||
When the `--preview` option is set, fzf automatically starts an external process
|
When the `--preview` option is set, fzf automatically starts an external process
|
||||||
|
12
doc/fzf.txt
12
doc/fzf.txt
@@ -154,8 +154,9 @@ Examples~
|
|||||||
\ 'ctrl-v': 'vsplit' }
|
\ 'ctrl-v': 'vsplit' }
|
||||||
|
|
||||||
" Default fzf layout
|
" Default fzf layout
|
||||||
" - down / up / left / right
|
" - down / up / left / right / window
|
||||||
let g:fzf_layout = { 'down': '~40%' }
|
let g:fzf_layout = { 'down': '~40%' }
|
||||||
|
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
|
||||||
|
|
||||||
" You can set up fzf window using a Vim command (Neovim or latest Vim 8 required)
|
" You can set up fzf window using a Vim command (Neovim or latest Vim 8 required)
|
||||||
let g:fzf_layout = { 'window': 'enew' }
|
let g:fzf_layout = { 'window': 'enew' }
|
||||||
@@ -305,8 +306,8 @@ When `window` entry is a dictionary, fzf will start in a popup window. The
|
|||||||
following options are allowed:
|
following options are allowed:
|
||||||
|
|
||||||
- Required:
|
- Required:
|
||||||
- `width` [float range [0 ~ 1]]
|
- `width` [float range [0 ~ 1]] or [integer range [8 ~ ]]
|
||||||
- `height` [float range [0 ~ 1]]
|
- `height` [float range [0 ~ 1]] or [integer range [4 ~ ]]
|
||||||
- Optional:
|
- Optional:
|
||||||
- `yoffset` [float default 0.5 range [0 ~ 1]]
|
- `yoffset` [float default 0.5 range [0 ~ 1]]
|
||||||
- `xoffset` [float default 0.5 range [0 ~ 1]]
|
- `xoffset` [float default 0.5 range [0 ~ 1]]
|
||||||
@@ -426,8 +427,9 @@ When fzf starts in a terminal buffer, the file type of the buffer is set to
|
|||||||
`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of
|
`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of
|
||||||
the window.
|
the window.
|
||||||
|
|
||||||
For example, if you use the default layout (`{'down': '~40%'}`) on Neovim, you
|
For example, if you use a non-popup layout (e.g. `{'down': '40%'}`) on
|
||||||
might want to temporarily disable the statusline for a cleaner look.
|
Neovim, you might want to temporarily disable the statusline for a cleaner
|
||||||
|
look.
|
||||||
>
|
>
|
||||||
if has('nvim') && !exists('g:fzf_layout')
|
if has('nvim') && !exists('g:fzf_layout')
|
||||||
autocmd! FileType fzf
|
autocmd! FileType fzf
|
||||||
|
2
go.mod
2
go.mod
@@ -1,7 +1,7 @@
|
|||||||
module github.com/junegunn/fzf
|
module github.com/junegunn/fzf
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gdamore/tcell v1.3.0
|
github.com/gdamore/tcell v1.4.0
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
|
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.12
|
github.com/mattn/go-isatty v0.0.12
|
||||||
github.com/mattn/go-runewidth v0.0.8
|
github.com/mattn/go-runewidth v0.0.8
|
||||||
|
5
go.sum
5
go.sum
@@ -1,8 +1,8 @@
|
|||||||
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||||
github.com/gdamore/tcell v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM=
|
github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU=
|
||||||
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
|
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4=
|
github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
|
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||||
@@ -11,6 +11,7 @@ github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHX
|
|||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
|
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
|
||||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||||
|
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0=
|
github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0=
|
||||||
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
github.com/mattn/go-shellwords v1.0.9 h1:eaB5JspOwiKKcHdqcjbfe5lA9cNn/4NRRtddXJCimqk=
|
github.com/mattn/go-shellwords v1.0.9 h1:eaB5JspOwiKKcHdqcjbfe5lA9cNn/4NRRtddXJCimqk=
|
||||||
|
14
install
14
install
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
version=0.22.0
|
version=0.23.0
|
||||||
auto_completion=
|
auto_completion=
|
||||||
key_bindings=
|
key_bindings=
|
||||||
update_config=2
|
update_config=2
|
||||||
@@ -28,9 +28,6 @@ usage: $0 [OPTIONS]
|
|||||||
--no-bash Do not set up bash configuration
|
--no-bash Do not set up bash configuration
|
||||||
--no-zsh Do not set up zsh configuration
|
--no-zsh Do not set up zsh configuration
|
||||||
--no-fish Do not set up fish configuration
|
--no-fish Do not set up fish configuration
|
||||||
|
|
||||||
--32 Download 32-bit binary
|
|
||||||
--64 Download 64-bit binary
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,8 +53,6 @@ for opt in "$@"; do
|
|||||||
--no-completion) auto_completion=0 ;;
|
--no-completion) auto_completion=0 ;;
|
||||||
--update-rc) update_config=1 ;;
|
--update-rc) update_config=1 ;;
|
||||||
--no-update-rc) update_config=0 ;;
|
--no-update-rc) update_config=0 ;;
|
||||||
--32) binary_arch=386 ;;
|
|
||||||
--64) binary_arch=amd64 ;;
|
|
||||||
--bin) ;;
|
--bin) ;;
|
||||||
--no-bash) shells=${shells/bash/} ;;
|
--no-bash) shells=${shells/bash/} ;;
|
||||||
--no-zsh) shells=${shells/zsh/} ;;
|
--no-zsh) shells=${shells/zsh/} ;;
|
||||||
@@ -179,24 +174,17 @@ binary_available=1
|
|||||||
binary_error=""
|
binary_error=""
|
||||||
case "$archi" in
|
case "$archi" in
|
||||||
Darwin\ *64) download fzf-$version-darwin_${binary_arch:-amd64}.tgz ;;
|
Darwin\ *64) download fzf-$version-darwin_${binary_arch:-amd64}.tgz ;;
|
||||||
Darwin\ *86) download fzf-$version-darwin_${binary_arch:-386}.tgz ;;
|
|
||||||
Linux\ armv5*) download fzf-$version-linux_${binary_arch:-arm5}.tgz ;;
|
Linux\ armv5*) download fzf-$version-linux_${binary_arch:-arm5}.tgz ;;
|
||||||
Linux\ armv6*) download fzf-$version-linux_${binary_arch:-arm6}.tgz ;;
|
Linux\ armv6*) download fzf-$version-linux_${binary_arch:-arm6}.tgz ;;
|
||||||
Linux\ armv7*) download fzf-$version-linux_${binary_arch:-arm7}.tgz ;;
|
Linux\ armv7*) download fzf-$version-linux_${binary_arch:-arm7}.tgz ;;
|
||||||
Linux\ armv8*) download fzf-$version-linux_${binary_arch:-arm8}.tgz ;;
|
Linux\ armv8*) download fzf-$version-linux_${binary_arch:-arm8}.tgz ;;
|
||||||
Linux\ aarch64*) download fzf-$version-linux_${binary_arch:-arm8}.tgz ;;
|
Linux\ aarch64*) download fzf-$version-linux_${binary_arch:-arm8}.tgz ;;
|
||||||
Linux\ *64) download fzf-$version-linux_${binary_arch:-amd64}.tgz ;;
|
Linux\ *64) download fzf-$version-linux_${binary_arch:-amd64}.tgz ;;
|
||||||
Linux\ *86) download fzf-$version-linux_${binary_arch:-386}.tgz ;;
|
|
||||||
FreeBSD\ *64) download fzf-$version-freebsd_${binary_arch:-amd64}.tgz ;;
|
FreeBSD\ *64) download fzf-$version-freebsd_${binary_arch:-amd64}.tgz ;;
|
||||||
FreeBSD\ *86) download fzf-$version-freebsd_${binary_arch:-386}.tgz ;;
|
|
||||||
OpenBSD\ *64) download fzf-$version-openbsd_${binary_arch:-amd64}.tgz ;;
|
OpenBSD\ *64) download fzf-$version-openbsd_${binary_arch:-amd64}.tgz ;;
|
||||||
OpenBSD\ *86) download fzf-$version-openbsd_${binary_arch:-386}.tgz ;;
|
|
||||||
CYGWIN*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;;
|
CYGWIN*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;;
|
||||||
MINGW*\ *86) download fzf-$version-windows_${binary_arch:-386}.zip ;;
|
|
||||||
MINGW*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;;
|
MINGW*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;;
|
||||||
MSYS*\ *86) download fzf-$version-windows_${binary_arch:-386}.zip ;;
|
|
||||||
MSYS*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;;
|
MSYS*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;;
|
||||||
Windows*\ *86) download fzf-$version-windows_${binary_arch:-386}.zip ;;
|
|
||||||
Windows*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;;
|
Windows*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;;
|
||||||
*) binary_available=0 binary_error=1 ;;
|
*) binary_available=0 binary_error=1 ;;
|
||||||
esac
|
esac
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
$version="0.22.0"
|
$version="0.23.0"
|
||||||
|
|
||||||
if ([Environment]::Is64BitProcess) {
|
if ([Environment]::Is64BitProcess) {
|
||||||
$binary_arch="amd64"
|
$binary_arch="amd64"
|
||||||
|
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
..
|
..
|
||||||
.TH fzf-tmux 1 "Aug 2020" "fzf 0.22.0" "fzf-tmux - open fzf in tmux split pane"
|
.TH fzf-tmux 1 "Oct 2020" "fzf 0.23.0" "fzf-tmux - open fzf in tmux split pane"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
fzf-tmux - open fzf in tmux split pane
|
fzf-tmux - open fzf in tmux split pane
|
||||||
|
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
..
|
..
|
||||||
.TH fzf 1 "Aug 2020" "fzf 0.22.0" "fzf - a command-line fuzzy finder"
|
.TH fzf 1 "Oct 2020" "fzf 0.23.0" "fzf - a command-line fuzzy finder"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
fzf - a command-line fuzzy finder
|
fzf - a command-line fuzzy finder
|
||||||
@@ -381,7 +381,7 @@ Preview window will be updated even when there is no match for the current
|
|||||||
query if any of the placeholder expressions evaluates to a non-empty string.
|
query if any of the placeholder expressions evaluates to a non-empty string.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.BI "--preview-window=" "[POSITION][:SIZE[%]][:noborder][:wrap][:hidden][:+SCROLL[-OFFSET]]"
|
.BI "--preview-window=" "[POSITION][:SIZE[%]][:rounded|sharp|noborder][:wrap][:hidden][:+SCROLL[-OFFSET]]"
|
||||||
Determines the layout of the preview window. If the argument contains
|
Determines the layout of the preview window. If the argument contains
|
||||||
\fB:hidden\fR, the preview window will be hidden by default until
|
\fB:hidden\fR, the preview window will be hidden by default until
|
||||||
\fBtoggle-preview\fR action is triggered. Long lines are truncated by default.
|
\fBtoggle-preview\fR action is triggered. Long lines are truncated by default.
|
||||||
@@ -390,11 +390,16 @@ Line wrap can be enabled with \fB:wrap\fR flag.
|
|||||||
If size is given as 0, preview window will not be visible, but fzf will still
|
If size is given as 0, preview window will not be visible, but fzf will still
|
||||||
execute the command in the background.
|
execute the command in the background.
|
||||||
|
|
||||||
|
To change the style of the border of the preview window, specify one of
|
||||||
|
\fBrounded\fR (border with rounded edges, default), \fBsharp\fR (border with
|
||||||
|
sharp edges), or \fBnoborder\fR (no border).
|
||||||
|
|
||||||
\fB+SCROLL[-OFFSET]\fR determines the initial scroll offset of the preview
|
\fB+SCROLL[-OFFSET]\fR determines the initial scroll offset of the preview
|
||||||
window. \fBSCROLL\fR can be either a numeric integer or a single-field index
|
window. \fBSCROLL\fR can be either a numeric integer or a single-field index
|
||||||
expression that refers to a numeric integer. The optional \fB-OFFSET\fR part is
|
expression that refers to a numeric integer. The optional \fB-OFFSET\fR part is
|
||||||
for adjusting the base offset so that you can see the text above it. It should
|
for adjusting the base offset so that you can see the text above it. It should
|
||||||
be given as a numeric integer.
|
be given as a numeric integer (\fB-INTEGER\fR), or as a denominator form
|
||||||
|
(\fB-/INTEGER\fR) for specifying a fraction of the preview window height.
|
||||||
|
|
||||||
.RS
|
.RS
|
||||||
.B POSITION: (default: right)
|
.B POSITION: (default: right)
|
||||||
@@ -411,9 +416,15 @@ e.g.
|
|||||||
fzf --preview="file {}" --preview-window=down:1
|
fzf --preview="file {}" --preview-window=down:1
|
||||||
|
|
||||||
# Initial scroll offset is set to the line number of each line of
|
# Initial scroll offset is set to the line number of each line of
|
||||||
# git grep output *minus* 5 lines
|
# git grep output *minus* 5 lines (-5)
|
||||||
git grep --line-number '' |
|
git grep --line-number '' |
|
||||||
fzf --delimiter : --preview 'nl {1}' --preview-window +{2}-5\fR
|
fzf --delimiter : --preview 'nl {1}' --preview-window +{2}-5
|
||||||
|
|
||||||
|
# Preview with bat, matching line in the middle of the window (-/2)
|
||||||
|
git grep --line-number '' |
|
||||||
|
fzf --delimiter : \\
|
||||||
|
--preview 'bat --style=numbers --color=always --highlight-line {2} {1}' \\
|
||||||
|
--preview-window +{2}-/2\fR
|
||||||
|
|
||||||
.RE
|
.RE
|
||||||
.SS Scripting
|
.SS Scripting
|
||||||
@@ -690,7 +701,6 @@ A key or an event can be bound to one or more of the following actions.
|
|||||||
\fBend-of-line\fR \fIctrl-e end\fR
|
\fBend-of-line\fR \fIctrl-e end\fR
|
||||||
\fBexecute(...)\fR (see below for the details)
|
\fBexecute(...)\fR (see below for the details)
|
||||||
\fBexecute-silent(...)\fR (see below for the details)
|
\fBexecute-silent(...)\fR (see below for the details)
|
||||||
\fRexecute-multi(...)\fR (deprecated in favor of \fB{+}\fR expression)
|
|
||||||
\fBforward-char\fR \fIctrl-f right\fR
|
\fBforward-char\fR \fIctrl-f right\fR
|
||||||
\fBforward-word\fR \fIalt-f shift-right\fR
|
\fBforward-word\fR \fIalt-f shift-right\fR
|
||||||
\fBignore\fR
|
\fBignore\fR
|
||||||
@@ -708,6 +718,8 @@ A key or an event can be bound to one or more of the following actions.
|
|||||||
\fBpreview-up\fR \fIshift-up\fR
|
\fBpreview-up\fR \fIshift-up\fR
|
||||||
\fBpreview-page-down\fR
|
\fBpreview-page-down\fR
|
||||||
\fBpreview-page-up\fR
|
\fBpreview-page-up\fR
|
||||||
|
\fBpreview-half-page-down\fR
|
||||||
|
\fBpreview-half-page-up\fR
|
||||||
\fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR)
|
\fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR)
|
||||||
\fBprint-query\fR (print query and exit)
|
\fBprint-query\fR (print query and exit)
|
||||||
\fBrefresh-preview\fR
|
\fBrefresh-preview\fR
|
||||||
|
@@ -115,7 +115,6 @@ function! s:fzf_tempname()
|
|||||||
return s:fzf_call('tempname')
|
return s:fzf_call('tempname')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:default_layout = { 'down': '~40%' }
|
|
||||||
let s:layout_keys = ['window', 'tmux', 'up', 'down', 'left', 'right']
|
let s:layout_keys = ['window', 'tmux', 'up', 'down', 'left', 'right']
|
||||||
let s:fzf_go = s:base_dir.'/bin/fzf'
|
let s:fzf_go = s:base_dir.'/bin/fzf'
|
||||||
let s:fzf_tmux = s:base_dir.'/bin/fzf-tmux'
|
let s:fzf_tmux = s:base_dir.'/bin/fzf-tmux'
|
||||||
@@ -123,6 +122,16 @@ let s:fzf_tmux = s:base_dir.'/bin/fzf-tmux'
|
|||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
|
function! s:popup_support()
|
||||||
|
return has('nvim') ? has('nvim-0.4') : has('popupwin') && has('patch-8.2.191')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:default_layout()
|
||||||
|
return s:popup_support()
|
||||||
|
\ ? { 'window' : { 'width': 0.9, 'height': 0.6, 'highlight': 'Normal' } }
|
||||||
|
\ : { 'down': '~40%' }
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! fzf#install()
|
function! fzf#install()
|
||||||
if s:is_win && !has('win32unix')
|
if s:is_win && !has('win32unix')
|
||||||
let script = s:base_dir.'/install.ps1'
|
let script = s:base_dir.'/install.ps1'
|
||||||
@@ -145,7 +154,7 @@ function! fzf#install()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:fzf_exec()
|
function! fzf#exec()
|
||||||
if !exists('s:exec')
|
if !exists('s:exec')
|
||||||
if executable(s:fzf_go)
|
if executable(s:fzf_go)
|
||||||
let s:exec = s:fzf_go
|
let s:exec = s:fzf_go
|
||||||
@@ -154,13 +163,13 @@ function! s:fzf_exec()
|
|||||||
elseif input('fzf executable not found. Download binary? (y/n) ') =~? '^y'
|
elseif input('fzf executable not found. Download binary? (y/n) ') =~? '^y'
|
||||||
redraw
|
redraw
|
||||||
call fzf#install()
|
call fzf#install()
|
||||||
return s:fzf_exec()
|
return fzf#exec()
|
||||||
else
|
else
|
||||||
redraw
|
redraw
|
||||||
throw 'fzf executable not found'
|
throw 'fzf executable not found'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
return fzf#shellescape(s:exec)
|
return s:exec
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:tmux_enabled()
|
function! s:tmux_enabled()
|
||||||
@@ -325,7 +334,7 @@ function! fzf#wrap(...)
|
|||||||
if !exists('g:fzf_layout') && exists('g:fzf_height')
|
if !exists('g:fzf_layout') && exists('g:fzf_height')
|
||||||
let opts.down = g:fzf_height
|
let opts.down = g:fzf_height
|
||||||
else
|
else
|
||||||
let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout)))
|
let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout())))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -376,7 +385,7 @@ try
|
|||||||
let temps = { 'result': s:fzf_tempname() }
|
let temps = { 'result': s:fzf_tempname() }
|
||||||
let optstr = s:evaluate_opts(get(dict, 'options', ''))
|
let optstr = s:evaluate_opts(get(dict, 'options', ''))
|
||||||
try
|
try
|
||||||
let fzf_exec = s:fzf_exec()
|
let fzf_exec = fzf#shellescape(fzf#exec())
|
||||||
catch
|
catch
|
||||||
throw v:exception
|
throw v:exception
|
||||||
endtry
|
endtry
|
||||||
@@ -658,7 +667,7 @@ function! s:split(dict)
|
|||||||
try
|
try
|
||||||
if s:present(a:dict, 'window')
|
if s:present(a:dict, 'window')
|
||||||
if type(a:dict.window) == type({})
|
if type(a:dict.window) == type({})
|
||||||
if !(has('nvim') ? has('nvim-0.4') : has('popupwin') && has('patch-8.2.191'))
|
if !s:popup_support()
|
||||||
throw 'Nvim 0.4+ or Vim 8.2.191+ with popupwin feature is required for pop-up window'
|
throw 'Nvim 0.4+ or Vim 8.2.191+ with popupwin feature is required for pop-up window'
|
||||||
end
|
end
|
||||||
call s:popup(a:dict.window)
|
call s:popup(a:dict.window)
|
||||||
@@ -864,9 +873,9 @@ function! s:popup(opts) abort
|
|||||||
let ambidouble = &ambiwidth == 'double' ? 2 : 1
|
let ambidouble = &ambiwidth == 'double' ? 2 : 1
|
||||||
|
|
||||||
" Size and position
|
" Size and position
|
||||||
let width = min([max([0, float2nr(&columns * a:opts.width)]), &columns])
|
let width = min([max([8, a:opts.width > 1 ? a:opts.width : float2nr(&columns * a:opts.width)]), &columns])
|
||||||
let width += width % ambidouble
|
let width += width % ambidouble
|
||||||
let height = min([max([0, float2nr(&lines * a:opts.height)]), &lines - has('nvim')])
|
let height = min([max([4, a:opts.height > 1 ? a:opts.height : float2nr(&lines * a:opts.height)]), &lines - has('nvim')])
|
||||||
let row = float2nr(get(a:opts, 'yoffset', 0.5) * (&lines - height))
|
let row = float2nr(get(a:opts, 'yoffset', 0.5) * (&lines - height))
|
||||||
let col = float2nr(get(a:opts, 'xoffset', 0.5) * (&columns - width))
|
let col = float2nr(get(a:opts, 'xoffset', 0.5) * (&columns - width))
|
||||||
|
|
||||||
|
@@ -272,7 +272,7 @@ _fzf_proc_completion_post() {
|
|||||||
|
|
||||||
_fzf_host_completion() {
|
_fzf_host_completion() {
|
||||||
_fzf_complete +m -- "$@" < <(
|
_fzf_complete +m -- "$@" < <(
|
||||||
cat <(cat ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?]') \
|
command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?]') \
|
||||||
<(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \
|
<(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \
|
||||||
<(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') |
|
<(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') |
|
||||||
awk '{if (length($2) > 0) {print $2}}' | sort -u
|
awk '{if (length($2) > 0) {print $2}}' | sort -u
|
||||||
|
@@ -225,7 +225,7 @@ _fzf_complete_telnet() {
|
|||||||
_fzf_complete_ssh() {
|
_fzf_complete_ssh() {
|
||||||
_fzf_complete +m -- "$@" < <(
|
_fzf_complete +m -- "$@" < <(
|
||||||
setopt localoptions nonomatch
|
setopt localoptions nonomatch
|
||||||
command cat <(cat ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?]') \
|
command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?]') \
|
||||||
<(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \
|
<(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \
|
||||||
<(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') |
|
<(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') |
|
||||||
awk '{if (length($2) > 0) {print $2}}' | sort -u
|
awk '{if (length($2) > 0) {print $2}}' | sort -u
|
||||||
|
@@ -87,9 +87,15 @@ fzf-cd-widget() {
|
|||||||
zle redisplay
|
zle redisplay
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$BUFFER" ]; then
|
||||||
|
BUFFER="cd ${(q)dir}"
|
||||||
|
zle accept-line
|
||||||
|
else
|
||||||
|
print -sr "cd ${(q)dir}"
|
||||||
cd "$dir"
|
cd "$dir"
|
||||||
unset dir # ensure this doesn't end up appearing in prompt expansion
|
fi
|
||||||
local ret=$?
|
local ret=$?
|
||||||
|
unset dir # ensure this doesn't end up appearing in prompt expansion
|
||||||
zle fzf-redraw-prompt
|
zle fzf-redraw-prompt
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
@@ -100,7 +106,7 @@ bindkey '\ec' fzf-cd-widget
|
|||||||
fzf-history-widget() {
|
fzf-history-widget() {
|
||||||
local selected num
|
local selected num
|
||||||
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
|
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
|
||||||
selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\s+(.*)/, $1)}++' |
|
selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\**\s+(.*)/, $1)}++' |
|
||||||
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
|
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
|
||||||
local ret=$?
|
local ret=$?
|
||||||
if [ -n "$selected" ]; then
|
if [ -n "$selected" ]; then
|
||||||
|
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// Current version
|
// Current version
|
||||||
version = "0.22.0"
|
version = "0.23.0"
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
coordinatorDelayMax time.Duration = 100 * time.Millisecond
|
coordinatorDelayMax time.Duration = 100 * time.Millisecond
|
||||||
|
@@ -80,7 +80,9 @@ const usage = `usage: fzf [options]
|
|||||||
Preview
|
Preview
|
||||||
--preview=COMMAND Command to preview highlighted line ({})
|
--preview=COMMAND Command to preview highlighted line ({})
|
||||||
--preview-window=OPT Preview window layout (default: right:50%)
|
--preview-window=OPT Preview window layout (default: right:50%)
|
||||||
[up|down|left|right][:SIZE[%]][:wrap][:hidden][:+SCROLL[-OFFSET]]
|
[up|down|left|right][:SIZE[%]][:wrap][:cycle][:hidden]
|
||||||
|
[:+SCROLL[-OFFSET]]
|
||||||
|
[:rounded|sharp|noborder]
|
||||||
|
|
||||||
Scripting
|
Scripting
|
||||||
-q, --query=STR Start the finder with the given query
|
-q, --query=STR Start the finder with the given query
|
||||||
@@ -162,7 +164,8 @@ type previewOpts struct {
|
|||||||
scroll string
|
scroll string
|
||||||
hidden bool
|
hidden bool
|
||||||
wrap bool
|
wrap bool
|
||||||
border bool
|
cycle bool
|
||||||
|
border tui.BorderShape
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options stores the values of command-line options
|
// Options stores the values of command-line options
|
||||||
@@ -261,7 +264,7 @@ func defaultOptions() *Options {
|
|||||||
ToggleSort: false,
|
ToggleSort: false,
|
||||||
Expect: make(map[int]string),
|
Expect: make(map[int]string),
|
||||||
Keymap: make(map[int][]action),
|
Keymap: make(map[int][]action),
|
||||||
Preview: previewOpts{"", posRight, sizeSpec{50, true}, "", false, false, true},
|
Preview: previewOpts{"", posRight, sizeSpec{50, true}, "", false, false, false, tui.BorderRounded},
|
||||||
PrintQuery: false,
|
PrintQuery: false,
|
||||||
ReadZero: false,
|
ReadZero: false,
|
||||||
Printer: func(str string) { fmt.Println(str) },
|
Printer: func(str string) { fmt.Println(str) },
|
||||||
@@ -853,6 +856,10 @@ func parseKeymap(keymap map[int][]action, str string) {
|
|||||||
appendAction(actPreviewPageUp)
|
appendAction(actPreviewPageUp)
|
||||||
case "preview-page-down":
|
case "preview-page-down":
|
||||||
appendAction(actPreviewPageDown)
|
appendAction(actPreviewPageDown)
|
||||||
|
case "preview-half-page-up":
|
||||||
|
appendAction(actPreviewHalfPageUp)
|
||||||
|
case "preview-half-page-down":
|
||||||
|
appendAction(actPreviewHalfPageDown)
|
||||||
default:
|
default:
|
||||||
t := isExecuteAction(specLower)
|
t := isExecuteAction(specLower)
|
||||||
if t == actIgnore {
|
if t == actIgnore {
|
||||||
@@ -987,15 +994,9 @@ func parseInfoStyle(str string) infoStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parsePreviewWindow(opts *previewOpts, input string) {
|
func parsePreviewWindow(opts *previewOpts, input string) {
|
||||||
// Default
|
|
||||||
opts.position = posRight
|
|
||||||
opts.size = sizeSpec{50, true}
|
|
||||||
opts.hidden = false
|
|
||||||
opts.wrap = false
|
|
||||||
|
|
||||||
tokens := strings.Split(input, ":")
|
tokens := strings.Split(input, ":")
|
||||||
sizeRegex := regexp.MustCompile("^[0-9]+%?$")
|
sizeRegex := regexp.MustCompile("^[0-9]+%?$")
|
||||||
offsetRegex := regexp.MustCompile("^\\+([0-9]+|{-?[0-9]+})(-[0-9]+)?$")
|
offsetRegex := regexp.MustCompile("^\\+([0-9]+|{-?[0-9]+})(-[0-9]+|-/[1-9][0-9]*)?$")
|
||||||
for _, token := range tokens {
|
for _, token := range tokens {
|
||||||
switch token {
|
switch token {
|
||||||
case "":
|
case "":
|
||||||
@@ -1003,6 +1004,8 @@ func parsePreviewWindow(opts *previewOpts, input string) {
|
|||||||
opts.hidden = true
|
opts.hidden = true
|
||||||
case "wrap":
|
case "wrap":
|
||||||
opts.wrap = true
|
opts.wrap = true
|
||||||
|
case "cycle":
|
||||||
|
opts.cycle = true
|
||||||
case "up", "top":
|
case "up", "top":
|
||||||
opts.position = posUp
|
opts.position = posUp
|
||||||
case "down", "bottom":
|
case "down", "bottom":
|
||||||
@@ -1011,10 +1014,12 @@ func parsePreviewWindow(opts *previewOpts, input string) {
|
|||||||
opts.position = posLeft
|
opts.position = posLeft
|
||||||
case "right":
|
case "right":
|
||||||
opts.position = posRight
|
opts.position = posRight
|
||||||
case "border":
|
case "rounded", "border":
|
||||||
opts.border = true
|
opts.border = tui.BorderRounded
|
||||||
|
case "sharp":
|
||||||
|
opts.border = tui.BorderSharp
|
||||||
case "noborder":
|
case "noborder":
|
||||||
opts.border = false
|
opts.border = tui.BorderNone
|
||||||
default:
|
default:
|
||||||
if sizeRegex.MatchString(token) {
|
if sizeRegex.MatchString(token) {
|
||||||
opts.size = parseSize(token, 99, "window size")
|
opts.size = parseSize(token, 99, "window size")
|
||||||
@@ -1025,14 +1030,6 @@ func parsePreviewWindow(opts *previewOpts, input string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !opts.size.percent && opts.size.size > 0 {
|
|
||||||
// Adjust size for border
|
|
||||||
opts.size.size += 2
|
|
||||||
// And padding
|
|
||||||
if opts.position == posLeft || opts.position == posRight {
|
|
||||||
opts.size.size += 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseMargin(margin string) [4]sizeSpec {
|
func parseMargin(margin string) [4]sizeSpec {
|
||||||
@@ -1274,7 +1271,7 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
opts.Preview.command = ""
|
opts.Preview.command = ""
|
||||||
case "--preview-window":
|
case "--preview-window":
|
||||||
parsePreviewWindow(&opts.Preview,
|
parsePreviewWindow(&opts.Preview,
|
||||||
nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:noborder][:wrap][:hidden][:+SCROLL[-OFFSET]]"))
|
nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:rounded|sharp|noborder][:wrap][:cycle][:hidden][:+SCROLL[-OFFSET]]"))
|
||||||
case "--height":
|
case "--height":
|
||||||
opts.Height = parseHeight(nextString(allArgs, &i, "height required: HEIGHT[%]"))
|
opts.Height = parseHeight(nextString(allArgs, &i, "height required: HEIGHT[%]"))
|
||||||
case "--min-height":
|
case "--min-height":
|
||||||
|
@@ -393,17 +393,18 @@ func TestPreviewOpts(t *testing.T) {
|
|||||||
opts.Preview.wrap == true &&
|
opts.Preview.wrap == true &&
|
||||||
opts.Preview.position == posLeft &&
|
opts.Preview.position == posLeft &&
|
||||||
opts.Preview.size.percent == false &&
|
opts.Preview.size.percent == false &&
|
||||||
opts.Preview.size.size == 15+2+2) {
|
opts.Preview.size.size == 15) {
|
||||||
t.Error(opts.Preview)
|
t.Error(opts.Preview)
|
||||||
}
|
}
|
||||||
opts = optsFor("--preview-window=up:15:wrap:hidden", "--preview-window=down")
|
opts = optsFor("--preview-window=up:15:wrap:hidden", "--preview-window=down", "--preview-window=cycle")
|
||||||
if !(opts.Preview.command == "" &&
|
if !(opts.Preview.command == "" &&
|
||||||
opts.Preview.hidden == false &&
|
opts.Preview.hidden == true &&
|
||||||
opts.Preview.wrap == false &&
|
opts.Preview.wrap == true &&
|
||||||
|
opts.Preview.cycle == true &&
|
||||||
opts.Preview.position == posDown &&
|
opts.Preview.position == posDown &&
|
||||||
opts.Preview.size.percent == true &&
|
opts.Preview.size.percent == false &&
|
||||||
opts.Preview.size.size == 50) {
|
opts.Preview.size.size == 15) {
|
||||||
t.Error(opts.Preview)
|
t.Error(opts.Preview.size.size)
|
||||||
}
|
}
|
||||||
opts = optsFor("--preview-window=up:15:wrap:hidden")
|
opts = optsFor("--preview-window=up:15:wrap:hidden")
|
||||||
if !(opts.Preview.command == "" &&
|
if !(opts.Preview.command == "" &&
|
||||||
@@ -411,7 +412,7 @@ func TestPreviewOpts(t *testing.T) {
|
|||||||
opts.Preview.wrap == true &&
|
opts.Preview.wrap == true &&
|
||||||
opts.Preview.position == posUp &&
|
opts.Preview.position == posUp &&
|
||||||
opts.Preview.size.percent == false &&
|
opts.Preview.size.percent == false &&
|
||||||
opts.Preview.size.size == 15+2) {
|
opts.Preview.size.size == 15) {
|
||||||
t.Error(opts.Preview)
|
t.Error(opts.Preview)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -236,6 +236,8 @@ const (
|
|||||||
actPreviewDown
|
actPreviewDown
|
||||||
actPreviewPageUp
|
actPreviewPageUp
|
||||||
actPreviewPageDown
|
actPreviewPageDown
|
||||||
|
actPreviewHalfPageUp
|
||||||
|
actPreviewHalfPageDown
|
||||||
actPreviousHistory
|
actPreviousHistory
|
||||||
actNextHistory
|
actNextHistory
|
||||||
actExecute
|
actExecute
|
||||||
@@ -612,12 +614,12 @@ const (
|
|||||||
maxDisplayWidthCalc = 1024
|
maxDisplayWidthCalc = 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
func calculateSize(base int, size sizeSpec, margin int, minSize int) int {
|
func calculateSize(base int, size sizeSpec, occupied int, minSize int, pad int) int {
|
||||||
max := base - margin
|
max := base - occupied
|
||||||
if size.percent {
|
if size.percent {
|
||||||
return util.Constrain(int(float64(base)*0.01*size.size), minSize, max)
|
return util.Constrain(int(float64(base)*0.01*size.size), minSize, max)
|
||||||
}
|
}
|
||||||
return util.Constrain(int(size.size), minSize, max)
|
return util.Constrain(int(size.size)+pad, minSize, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Terminal) resizeWindows() {
|
func (t *Terminal) resizeWindows() {
|
||||||
@@ -676,6 +678,8 @@ func (t *Terminal) resizeWindows() {
|
|||||||
}
|
}
|
||||||
if t.pborder != nil {
|
if t.pborder != nil {
|
||||||
t.pborder.Close()
|
t.pborder.Close()
|
||||||
|
}
|
||||||
|
if t.pwindow != nil {
|
||||||
t.pwindow.Close()
|
t.pwindow.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -700,38 +704,51 @@ func (t *Terminal) resizeWindows() {
|
|||||||
noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode)
|
noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode)
|
||||||
if previewVisible {
|
if previewVisible {
|
||||||
createPreviewWindow := func(y int, x int, w int, h int) {
|
createPreviewWindow := func(y int, x int, w int, h int) {
|
||||||
previewBorder := tui.MakeBorderStyle(tui.BorderRounded, t.unicode)
|
pwidth := w
|
||||||
if !t.preview.border {
|
pheight := h
|
||||||
previewBorder = tui.MakeTransparentBorder()
|
if t.preview.border != tui.BorderNone {
|
||||||
}
|
previewBorder := tui.MakeBorderStyle(t.preview.border, t.unicode)
|
||||||
t.pborder = t.tui.NewWindow(y, x, w, h, true, previewBorder)
|
t.pborder = t.tui.NewWindow(y, x, w, h, true, previewBorder)
|
||||||
pwidth := w - 4
|
pwidth -= 4
|
||||||
|
pheight -= 2
|
||||||
|
x += 2
|
||||||
|
y += 1
|
||||||
|
} else {
|
||||||
|
previewBorder := tui.MakeTransparentBorder()
|
||||||
|
t.pborder = t.tui.NewWindow(y, x, w, h, true, previewBorder)
|
||||||
|
pwidth -= 4
|
||||||
|
x += 2
|
||||||
|
}
|
||||||
// ncurses auto-wraps the line when the cursor reaches the right-end of
|
// ncurses auto-wraps the line when the cursor reaches the right-end of
|
||||||
// the window. To prevent unintended line-wraps, we use the width one
|
// the window. To prevent unintended line-wraps, we use the width one
|
||||||
// column larger than the desired value.
|
// column larger than the desired value.
|
||||||
if !t.preview.wrap && t.tui.DoesAutoWrap() {
|
if !t.preview.wrap && t.tui.DoesAutoWrap() {
|
||||||
pwidth += 1
|
pwidth += 1
|
||||||
}
|
}
|
||||||
t.pwindow = t.tui.NewWindow(y+1, x+2, pwidth, h-2, true, noBorder)
|
t.pwindow = t.tui.NewWindow(y, x, pwidth, pheight, true, noBorder)
|
||||||
|
}
|
||||||
|
verticalPad := 2
|
||||||
|
if t.preview.border == tui.BorderNone {
|
||||||
|
verticalPad = 0
|
||||||
}
|
}
|
||||||
switch t.preview.position {
|
switch t.preview.position {
|
||||||
case posUp:
|
case posUp:
|
||||||
pheight := calculateSize(height, t.preview.size, minHeight, 3)
|
pheight := calculateSize(height, t.preview.size, minHeight, 3, verticalPad)
|
||||||
t.window = t.tui.NewWindow(
|
t.window = t.tui.NewWindow(
|
||||||
marginInt[0]+pheight, marginInt[3], width, height-pheight, false, noBorder)
|
marginInt[0]+pheight, marginInt[3], width, height-pheight, false, noBorder)
|
||||||
createPreviewWindow(marginInt[0], marginInt[3], width, pheight)
|
createPreviewWindow(marginInt[0], marginInt[3], width, pheight)
|
||||||
case posDown:
|
case posDown:
|
||||||
pheight := calculateSize(height, t.preview.size, minHeight, 3)
|
pheight := calculateSize(height, t.preview.size, minHeight, 3, verticalPad)
|
||||||
t.window = t.tui.NewWindow(
|
t.window = t.tui.NewWindow(
|
||||||
marginInt[0], marginInt[3], width, height-pheight, false, noBorder)
|
marginInt[0], marginInt[3], width, height-pheight, false, noBorder)
|
||||||
createPreviewWindow(marginInt[0]+height-pheight, marginInt[3], width, pheight)
|
createPreviewWindow(marginInt[0]+height-pheight, marginInt[3], width, pheight)
|
||||||
case posLeft:
|
case posLeft:
|
||||||
pwidth := calculateSize(width, t.preview.size, minWidth, 5)
|
pwidth := calculateSize(width, t.preview.size, minWidth, 5, 4)
|
||||||
t.window = t.tui.NewWindow(
|
t.window = t.tui.NewWindow(
|
||||||
marginInt[0], marginInt[3]+pwidth, width-pwidth, height, false, noBorder)
|
marginInt[0], marginInt[3]+pwidth, width-pwidth, height, false, noBorder)
|
||||||
createPreviewWindow(marginInt[0], marginInt[3], pwidth, height)
|
createPreviewWindow(marginInt[0], marginInt[3], pwidth, height)
|
||||||
case posRight:
|
case posRight:
|
||||||
pwidth := calculateSize(width, t.preview.size, minWidth, 5)
|
pwidth := calculateSize(width, t.preview.size, minWidth, 5, 4)
|
||||||
t.window = t.tui.NewWindow(
|
t.window = t.tui.NewWindow(
|
||||||
marginInt[0], marginInt[3], width-pwidth, height, false, noBorder)
|
marginInt[0], marginInt[3], width-pwidth, height, false, noBorder)
|
||||||
createPreviewWindow(marginInt[0], marginInt[3]+width-pwidth, pwidth, height)
|
createPreviewWindow(marginInt[0], marginInt[3]+width-pwidth, pwidth, height)
|
||||||
@@ -1037,7 +1054,7 @@ func (t *Terminal) printHighlighted(result Result, attr tui.Attr, col1 tui.Color
|
|||||||
}
|
}
|
||||||
|
|
||||||
offsets := result.colorOffsets(charOffsets, t.theme, col2, attr, current)
|
offsets := result.colorOffsets(charOffsets, t.theme, col2, attr, current)
|
||||||
maxWidth := t.window.Width() - 3
|
maxWidth := t.window.Width() - (t.pointerLen + t.markerLen + 1)
|
||||||
maxe = util.Constrain(maxe+util.Min(maxWidth/2-2, t.hscrollOff), 0, len(text))
|
maxe = util.Constrain(maxe+util.Min(maxWidth/2-2, t.hscrollOff), 0, len(text))
|
||||||
displayWidth := t.displayWidthWithLimit(text, 0, maxWidth)
|
displayWidth := t.displayWidthWithLimit(text, 0, maxWidth)
|
||||||
if displayWidth > maxWidth {
|
if displayWidth > maxWidth {
|
||||||
@@ -1210,7 +1227,10 @@ func (t *Terminal) refresh() {
|
|||||||
windows = append(windows, t.border)
|
windows = append(windows, t.border)
|
||||||
}
|
}
|
||||||
if t.hasPreviewWindow() {
|
if t.hasPreviewWindow() {
|
||||||
windows = append(windows, t.pborder, t.pwindow)
|
if t.pborder != nil {
|
||||||
|
windows = append(windows, t.pborder)
|
||||||
|
}
|
||||||
|
windows = append(windows, t.pwindow)
|
||||||
}
|
}
|
||||||
windows = append(windows, t.window)
|
windows = append(windows, t.window)
|
||||||
t.tui.RefreshWindows(windows)
|
t.tui.RefreshWindows(windows)
|
||||||
@@ -1374,7 +1394,7 @@ func atopi(s string) int {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Terminal) evaluateScrollOffset(list []*Item) int {
|
func (t *Terminal) evaluateScrollOffset(list []*Item, height int) int {
|
||||||
offsetExpr := t.replacePlaceholder(t.preview.scroll, false, "", list)
|
offsetExpr := t.replacePlaceholder(t.preview.scroll, false, "", list)
|
||||||
nums := strings.Split(offsetExpr, "-")
|
nums := strings.Split(offsetExpr, "-")
|
||||||
switch len(nums) {
|
switch len(nums) {
|
||||||
@@ -1387,6 +1407,13 @@ func (t *Terminal) evaluateScrollOffset(list []*Item) int {
|
|||||||
} else if len(nums) == 1 {
|
} else if len(nums) == 1 {
|
||||||
return base - 1
|
return base - 1
|
||||||
}
|
}
|
||||||
|
if nums[1][0] == '/' {
|
||||||
|
denom := atopi(nums[1][1:])
|
||||||
|
if denom == 0 {
|
||||||
|
return base
|
||||||
|
}
|
||||||
|
return base - height/denom
|
||||||
|
}
|
||||||
return base - atopi(nums[1]) - 1
|
return base - atopi(nums[1]) - 1
|
||||||
default:
|
default:
|
||||||
return 0
|
return 0
|
||||||
@@ -1532,8 +1559,8 @@ func (t *Terminal) currentItem() *Item {
|
|||||||
|
|
||||||
func (t *Terminal) buildPlusList(template string, forcePlus bool) (bool, []*Item) {
|
func (t *Terminal) buildPlusList(template string, forcePlus bool) (bool, []*Item) {
|
||||||
current := t.currentItem()
|
current := t.currentItem()
|
||||||
_, plus, query := hasPreviewFlags(template)
|
slot, plus, query := hasPreviewFlags(template)
|
||||||
if !(query && len(t.input) > 0 || (forcePlus || plus) && len(t.selected) > 0) {
|
if !(!slot || query && len(t.input) > 0 || (forcePlus || plus) && len(t.selected) > 0) {
|
||||||
return current != nil, []*Item{current, current}
|
return current != nil, []*Item{current, current}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1676,11 +1703,13 @@ func (t *Terminal) Loop() {
|
|||||||
// We don't display preview window if no match
|
// We don't display preview window if no match
|
||||||
if items[0] != nil {
|
if items[0] != nil {
|
||||||
command := t.replacePlaceholder(commandTemplate, false, string(t.Input()), items)
|
command := t.replacePlaceholder(commandTemplate, false, string(t.Input()), items)
|
||||||
offset := t.evaluateScrollOffset(items)
|
offset := 0
|
||||||
cmd := util.ExecCommand(command, true)
|
cmd := util.ExecCommand(command, true)
|
||||||
if t.pwindow != nil {
|
if t.pwindow != nil {
|
||||||
|
height := t.pwindow.Height()
|
||||||
|
offset = t.evaluateScrollOffset(items, height)
|
||||||
env := os.Environ()
|
env := os.Environ()
|
||||||
lines := fmt.Sprintf("LINES=%d", t.pwindow.Height())
|
lines := fmt.Sprintf("LINES=%d", height)
|
||||||
columns := fmt.Sprintf("COLUMNS=%d", t.pwindow.Width())
|
columns := fmt.Sprintf("COLUMNS=%d", t.pwindow.Width())
|
||||||
env = append(env, lines)
|
env = append(env, lines)
|
||||||
env = append(env, "FZF_PREVIEW_"+lines)
|
env = append(env, "FZF_PREVIEW_"+lines)
|
||||||
@@ -1859,8 +1888,11 @@ func (t *Terminal) Loop() {
|
|||||||
if !t.previewer.more {
|
if !t.previewer.more {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newOffset := util.Constrain(
|
newOffset := t.previewer.offset + amount
|
||||||
t.previewer.offset+amount, 0, t.previewer.lines-1)
|
if t.preview.cycle {
|
||||||
|
newOffset = (newOffset + t.previewer.lines) % t.previewer.lines
|
||||||
|
}
|
||||||
|
newOffset = util.Constrain(newOffset, 0, t.previewer.lines-1)
|
||||||
if t.previewer.offset != newOffset {
|
if t.previewer.offset != newOffset {
|
||||||
t.previewer.offset = newOffset
|
t.previewer.offset = newOffset
|
||||||
req(reqPreviewRefresh)
|
req(reqPreviewRefresh)
|
||||||
@@ -1930,6 +1962,14 @@ func (t *Terminal) Loop() {
|
|||||||
if t.hasPreviewWindow() {
|
if t.hasPreviewWindow() {
|
||||||
scrollPreview(t.pwindow.Height())
|
scrollPreview(t.pwindow.Height())
|
||||||
}
|
}
|
||||||
|
case actPreviewHalfPageUp:
|
||||||
|
if t.hasPreviewWindow() {
|
||||||
|
scrollPreview(-t.pwindow.Height() / 2)
|
||||||
|
}
|
||||||
|
case actPreviewHalfPageDown:
|
||||||
|
if t.hasPreviewWindow() {
|
||||||
|
scrollPreview(t.pwindow.Height() / 2)
|
||||||
|
}
|
||||||
case actBeginningOfLine:
|
case actBeginningOfLine:
|
||||||
t.cx = 0
|
t.cx = 0
|
||||||
case actBackwardChar:
|
case actBackwardChar:
|
||||||
|
@@ -3,7 +3,6 @@ package tui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -126,17 +125,6 @@ func NewLightRenderer(theme *ColorTheme, forceBlack bool, mouse bool, tabstop in
|
|||||||
return &r
|
return &r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *LightRenderer) defaultTheme() *ColorTheme {
|
|
||||||
if strings.Contains(os.Getenv("TERM"), "256") {
|
|
||||||
return Dark256
|
|
||||||
}
|
|
||||||
colors, err := exec.Command("tput", "colors").Output()
|
|
||||||
if err == nil && atoi(strings.TrimSpace(string(colors)), 16) > 16 {
|
|
||||||
return Dark256
|
|
||||||
}
|
|
||||||
return Default16
|
|
||||||
}
|
|
||||||
|
|
||||||
func repeat(r rune, times int) string {
|
func repeat(r rune, times int) string {
|
||||||
if times > 0 {
|
if times > 0 {
|
||||||
return strings.Repeat(string(r), times)
|
return strings.Repeat(string(r), times)
|
||||||
|
@@ -5,6 +5,8 @@ package tui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/junegunn/fzf/src/util"
|
"github.com/junegunn/fzf/src/util"
|
||||||
@@ -15,6 +17,17 @@ func IsLightRendererSupported() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *LightRenderer) defaultTheme() *ColorTheme {
|
||||||
|
if strings.Contains(os.Getenv("TERM"), "256") {
|
||||||
|
return Dark256
|
||||||
|
}
|
||||||
|
colors, err := exec.Command("tput", "colors").Output()
|
||||||
|
if err == nil && atoi(strings.TrimSpace(string(colors)), 16) > 16 {
|
||||||
|
return Dark256
|
||||||
|
}
|
||||||
|
return Default16
|
||||||
|
}
|
||||||
|
|
||||||
func (r *LightRenderer) fd() int {
|
func (r *LightRenderer) fd() int {
|
||||||
return int(r.ttyin.Fd())
|
return int(r.ttyin.Fd())
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,14 @@ func IsLightRendererSupported() bool {
|
|||||||
return canSetVt100
|
return canSetVt100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *LightRenderer) defaultTheme() *ColorTheme {
|
||||||
|
// the getenv check is borrowed from here: https://github.com/gdamore/tcell/commit/0c473b86d82f68226a142e96cc5a34c5a29b3690#diff-b008fcd5e6934bf31bc3d33bf49f47d8R178:
|
||||||
|
if !IsLightRendererSupported() || os.Getenv("ConEmuPID") != "" || os.Getenv("TCELL_TRUECOLOR") == "disable" {
|
||||||
|
return Default16
|
||||||
|
}
|
||||||
|
return Dark256
|
||||||
|
}
|
||||||
|
|
||||||
func (r *LightRenderer) initPlatform() error {
|
func (r *LightRenderer) initPlatform() error {
|
||||||
//outHandle := windows.Stdout
|
//outHandle := windows.Stdout
|
||||||
outHandle, _ := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
|
outHandle, _ := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
|
||||||
|
Reference in New Issue
Block a user