-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tag specific preview and cycling #79
Comments
# for command
zstyle ':fzf-tab:complete:-command-:*' extra-opts --preview=$extract'
which ${~ctxt[hpre]}$in | grep -v "not found" 2> /dev/null;
whatis ${~ctxt[hpre]}$in 2> /dev/null;
man "${~ctxt[hpre]}$in" 2> /dev/null |col -bx|awk -v S="$2" "DESCRIPTION ~ S {cap="true"; print} DESCRIPTION !~ S && /^[A-Z ]+$/ {cap="false"} DESCRIPTION !~ S && !/^[A-Z ]+$/ {if(cap == "true")print}" 2> /dev/null;
'
# for options
zstyle ':fzf-tab:complete:*:options' extra-opts --preview=$extract'echo $in'
|
@Aloxaf Can context target files, for any command? I would like In general, are the available fzf-tab |
For most command, you can use
Unfortunately, there aren't. There are command-specific, though most command will repect to a regular format. You may find some useful information here.
Just replace |
So this is what im doing at the moment but I'm still unsatisfied fzf_tab_preview_commit='
# Show commits and branch commits
git show $( echo "$in" | cut -f 1 -d " " ) | diff-so-fancy --colors
'
fzf_tab_preview_options=''
fzf_tab_preview_command='
# Show information on command
which ${~ctxt[hpre]}$in | grep -v "not found" 2> /dev/null;
whatis ${~ctxt[hpre]}$in 2> /dev/null;
# Show my own snippets related to the command
grep -w "$in" ~/.config/clisnippets 2> /dev/null;
# tldr show cheatsheet of command
tldr $in 2> /dev/null;
# Search through man and give the description segment
man "${~ctxt[hpre]}$in" 2> /dev/null |col -bx|awk -v S="$2" "DESCRIPTION ~ S {cap="true"; print} DESCRIPTION !~ S && /^[A-Z ]+$/ {cap="false"} DESCRIPTION !~ S && !/^[A-Z ]+$/ {if(cap == "true")print}" 2> /dev/null;
'
fzf_tab_preview_file='
# Display images
tiv -h ${FZF_PREVIEW_LINES} -w ${FZF_PREVIEW_COLUMNS} $in 2> /dev/null;
# Display directory
# du -h ${~ctxt[hpre]}$in 2> /dev/null | tail -n1
lsd --tree --icon --depth 2 --color=always $in 2> /dev/null
# exa -1 --color=always $in 2> /dev/null;
# Display file
bat --theme="OneHalfDark" --style=numbers,changes --color always $in 2> /dev/null | head -n50 | grep -v "bat warning"; 2> /dev/null;
# Display exif data
exiftool $in 2> /dev/null;
'
fzf_tab_preview_systemctl_service='
systemctl status $in
systemctl help $in
'
zstyle ':fzf-tab:complete:*' extra-opts --preview=$extract$fzf_tab_preview_file
zstyle ':fzf-tab:complete:*:options' extra-opts '' # --preview=$extract$fzf_tab_preview_options
zstyle ':fzf-tab:complete:-command-:*' extra-opts --preview=$extract$fzf_tab_preview_command
zstyle ':fzf-tab:complete:git*:*' extra-opts --preview=$extract$fzf_tab_preview_commit$fzf_tab_preview_file
zstyle ':fzf-tab:complete:systemctl*:*' extra-opts --preview=$extract$fzf_tab_preview_systemctl_service
However this is not really the way I want to achieve it, I don't really get how to interpret the result of tags in context :completion::complete:git::
argument-rest (_arguments _git _git)
tags in context :completion::complete:git-checkout::
argument-rest options (_arguments _git-checkout _git _git)
tags in context :completion::complete:git-checkout:argument-rest:
modified-files tree-ishs remote-branch-names-noprefix (_git-checkout _git _git)
modified-files (__git_files __git_modified_files _git-checkout _git _git)
recent-branches commits (__git_commits_prefer_recent _git-checkout _git _git)
recent-branches (__git_recent_branches __git_commits_prefer_recent _git-checkout _git _git) I would like to be able to target each tag differently for example zstyle ':fzf-tab:complete:git*:commits' extra-opts --preview=$extract' echo Commits\n; '$fzf_tab_preview_commit$fzf_tab_preview_file
zstyle ':fzf-tab:complete:git*:modified-files' extra-opts --preview=$extract' echo Modified files \n; '$fzf_tab_preview_commit$fzf_tab_preview_file or even better something like zstyle ':fzf-tab:complete:*:*' extra-opts --preview=$extract' tag=$extractedTagName
if [[ tag == "file" ]]; then
fi
if [[ tag == "commits" ]]; then
fi
if [[ tag == "recent branches" ]]; then
fi
' |
Ummm, there may need a way to extract the group name. |
Indeed with extracted group name and tag and context string we could really leverage a lot of interesting preview easily |
@adelin-b That gif looks fantastic, thanks for posting it, and the code that goes with it!
|
Here is an updated version of this code snippet as they were breaking changes since.
|
@adelin-b Thanks a lot! |
It should be working now, mind that there will be a revision of this gist to escape the completion string to prevent injection @magnetophon |
It is actually really usefull but not much people ive shown this like it as it look clutered
It replace packages like https://github.com/wfxr/forgit https://github.com/chriswalz/bit and all of thoses |
I imagine that if @Aloxaf ads this to fzf-tab, it will be an option. |
Sorry, the answer is no. Though this configuration is cool, it goes beyond the purpose of this repo. |
@Aloxaf Ok, fair enough. |
@Aloxaf it also goes beyond the scope of this issues which is getting the |
Is your feature request related to a problem? Please describe.
Im trying to define different preview specific to the type/tag of the completion, for example it can be either a command / folder / textfile / image / aliases
vim
Describe the solution you'd like
Actually Im using
I would like to be able to handle all kind of completion types like options / commits / users / services / diff / urls.
So the extra ops should have a way to know which kind of tag is previewed.
Hence thoses questions that are in the way:
which g
work inside a shell but not when im trying to show it during the completion preview)imageFile
would have 2 preview mode:exif
andterminal preview
)Here is what the code above do, im using tiv for the image display and bat for the code
The text was updated successfully, but these errors were encountered: