Skip to content

Commit

Permalink
📝 Improve customize section of README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Feb 11, 2024
1 parent f4119b6 commit 8cb0c71
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ source /the/directory/of/this/plugin/*.plugin.zsh

**NOTE**: Don't source `*.zsh`! They will be sourced by `*.plugin.zsh` automatically.

## Customize

You can use your customized fzf-tab sources to override the default, such as:

```zsh
zstyle ':fzf-tab:sources' config-directory /the/directory/containing/your/source.zsh
```

## Preview

You need some optional tools:
Expand Down Expand Up @@ -223,6 +215,30 @@ display text.

![adb](https://user-images.githubusercontent.com/32936898/203727602-e33b617d-a218-435e-8f8a-585e7679857f.jpg)

## Customize

### Sources

```zsh
zstyle ':fzf-tab:sources' config-directory /a/directory
```

You can use your customized fzf-tab sources to override
[this plugin's sources](sources).
`*.zsh` in `config-directory` are standalone zsh scripts which can be syntax
highlighted by your editor:

```zsh
# :fzf-tab:complete:context --optional-fzf-option
foobar $word
```

- Built-in commands and aliases should start with `(\\|)` to support `\command`
- Commands should start with `(\\|*/|)` to support `=command`

That is, `\command <TAB>`, `=command <TAB>` will get same preview windows as
`command <TAB>`.

### Similar Project

- [fifc](https://github.com/gazorby/fifc):
Expand Down
15 changes: 7 additions & 8 deletions fzf-tab-source.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"

# config
local dir=${0:h} config_directory
zstyle -s ':fzf-tab:sources' config-directory config_directory
local sources=()
local sources=($dir/sources/*.zsh)
# use user's sources to override this plugin's sources
if [[ -n $config_directory ]]; then
sources=($config_directory/**/*.zsh(.N))
sources+=($config_directory/**/*.zsh(.N))
fi

# https://github.com/Freed-Wu/fzf-tab-source/issues/11
# enable $group
zstyle ':completion:*:descriptions' format %d

# use a standalone script to get syntax highlight
# built-in commands and aliases should start with `(\\|)` to support `\command`
# commands should start with `(\\|*/|)` to support `=command`
local dir=${0:h} src line arr ctx flags
for src in $dir/sources/*.zsh $sources; do
local src line arr ctx flags
for src in $sources; do
while read -r line; do
# strip code to get magic comment
arr=(${(@s. .)line##\# })
ctx=${arr[1]}
if [[ $ctx == ':fzf-tab:'* ]]; then
Expand Down

0 comments on commit 8cb0c71

Please sign in to comment.