rockandska / fzf-obc Goto Github PK
View Code? Open in Web Editor NEWfzf over bash complete
fzf over bash complete
Hello,
I've been using https://github.com/lincheney/fzf-tab-completion/ but want to try fzf-obc as it supports completion post functions.
Is there a basic example to make a custom completion function work with fzf-obc?
Bash version: GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
_foo() {
COMPREPLY=()
local cur
cur=$(_get_cword)
local completions="10foo - first foo
11foo - second foo
12foo - third foo"
local OLDIFS="$IFS"
local IFS=$'\n'
COMPREPLY=( $( compgen -W "$completions" -- "$cur" ) )
IFS="$OLDIFS"
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then #Only one completion
COMPREPLY=( ${COMPREPLY[0]%% - *} ) #Remove ' - ' and everything after
fi
return 0
} && complete -F _foo foo
After source'ing fzf-obc
source <path-to-fzf-obc>/fzf-obc.bash
When I press foo <tab-key>
, I don't see the completions using the fzf-filter. I only see the default method of completion of bash.
complete -p foo
returns complete -F __fzf_obc_wrapper__foo foo
, so fzf-obc seems to be doing something but doesn't show the candidates in fzf.
However, when I use it one of the standard linux commands, e.g. ls -
, then I see the ls
options using the fzf window.
Am I missing an important step to make fzf-obc work with custom completion functions?
Thanks in advance.
Even with pressing ctl-c
, the search hang until its finished.
Rare but happen, ctrl-c
break the escape keystroke
My ~/.config
contains only a few things, and fzf-obc
is the only item starting with f
.
Type cd ~/.config/f
Expected: completes to cd ~/.config/fzf-obc/
(default bash completion does so)
Actual: fzf is triggered, displaying 2/2 results, one is fzf-obc/, one is an empty line (selecting that results in cd ~/.config/f/
which does not exist)
Same issue when trying to ls ~/.bashr
(expected .bashrc
, actual 2/2 results, one is .bashrc
, one is an empty line - selecting that one results in ~/.bashr/
).
macOS, bash 5.0.11 from homebrew, latest git version of fzf-obc (1.3.0)
This project does not seem to have a license declared in an obvious way, or at all. A license should be added (as this project seems to be intended as open source) so that users can run, modify, study, distribute, and use the code.
Introduced by 1600f64
current -> /var/guix/profiles/per-user/rockandska/current-guix
doesn't appear in the results for example
With plain fzf integration I can hit Ctrl-R and search history with fzf.
With fzf-obc the standard "reverse-i-search" is used.
This probably can be fixed by simply sourcing /usr/local/opt/fzf/shell/key-bindings.bash
as it was previously done in ~/.fzf.bash
Is it possible to implement something similar to this?
So candidates would be displayed right under current cursor position.
[prompt]: git sta|
stage
stash
status
Thank you for the package btw ๐
I've installed this per the instructions, but attempting to use tab completion results in this error being printed:
bash: /proc/cpuinfo: No such file or directory
There is no /proc on macOS.
The completion itself seems to be working, although with the annoying error message on every attempt to use it, I didn't do any extensive testing.
Hey, not sure where to ask, I noticed there was a v2 branch with recent updates, any info on if it's usable/should be beta tested/etc?
Actual behavior :
git stash drop stash@\{0\}
Desired bahavior :
git stash drop stash@{0}
Thank you for you this amazing tool!
Addition of readline completion would allow for an even more pleasant experience.
fzf-tab-completion (https://github.com/lincheney/fzf-tab-completion) is a great tool, but lacks the customizablility fzf-obc provides. However it has readline completion which is very useful.
If possible, please consider adding similar functionality to fzf-obc.
Perhaps this is by design, in which case would be nice to hear the motivation behind that. It is mentioned in the README that the hotkey is .
When not using fzf-obc, one is used to complete the currently typed text, while a shows the whole list of available completions. With fzf-obc, habitually typing ls /<TAB><TAB>
results in the completion list showing due to the first , and then the first item in the list being selected due to the second one. Of course a user can re-train their behavior if necessary, but I wonder if that is useful, perhaps it would be better to keep the traditional way?
OS: macOS 10.15.1
Something is wrong with the sort order of the results displayed by fzf-obc.
Without fzf-obc, ls /[TAB][TAB]
:
.DS_Store .vol/ System/ cores/ opt/ usr/
.VolumeIcon.icns Applications/ Users/ dev/ private/ var/
.file Library/ Volumes/ etc/ sbin/
.fseventsd/ Network/ bin/ home/ tmp/
With fzf-obc enabled:
$ ls /
>
22/22
> Volumes/
var/
usr/
Users/
tmp/
System/
sbin/
private/
opt/
Network/
Library/
home/
etc/
Note that the order of the result is reverse alphabetic, and case seems to be ignored.
Original sort order is alphabetic, with all uppercase letters before all lowercase ones.
it would be nice if case-insensitive matching were automatically enabled
when the readline option completion-ignore-case
is on
maybe useful to consider other readline options too
I don't suppose there is some way to make recursive completion async (like vanilla fzf
)?
For example i have something like this before the cursor (fzf-obc[master] is a prompt in this case):
fzf-obc[master]: git sta|
And after status is selected the result is just:
tus
|
And when Enter being hit the correct git status command is executed.
The problem is reproduced without any bashrc except sourcing bash_completion.
I installed the latest fzf and fzf-obc from git
When I try to run the example ls /s[TAB] and choose any directory the ansi codes are pasted.
I have tried searching for solutions but have not found anything.
I am running
WSL Ububtu 20.04
fzf 0.27.2 (e086f0b)
fzf-obc fdfb34d
Gif below:
Thank you, this is amazing!
I have tried to configure bindings as shown via the wiki page but have been unsuccessful.
Most importantly:
Also:
*
or **
before tab?Thank you again, its really appreciated! amazing work!!
MacOS has a bit different flavor of coreutils and currently fzf-obc doesn't work on MacOS.
On MacOS there are the following incompatibilities with modern linux distributions:
-r
(I think -E
is used instead) and -z
optionshead -n -1
syntax is not supported. head -n 1
works fine (don't know if in intended way or not)-z
optionProbably a few more options could be unsupported โ I gave up at this point.
I'm using MacOS 10.14.6 Mojave and tried to select tag 1.2.0 for installation.
$ ls -al
total 8
drwx------ 2 mrich mrich 4096 Sep 17 22:19 .
drwxrwxrwt 32 root root 4096 Sep 17 22:19 ..
-rw-rw-r-- 1 mrich mrich 0 Sep 17 22:19 TEST
$ less t<TAB>
Nothing happens after pressing TAB
. I have completion-ignore-case On
, so I would expect it to show TEST
. Since fzf-obc
does not automatically pick up completion-ignore-case
as per #29 I tried your suggestion of std_fzf_opts+=' +i'
but that didn't help either.
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
I noticed this as I sometimes use backslash to override aliases
$ \cd <tab>
$ \cd ^[\[01\;34m/usr/^[\[0m
note that mv \x <tab>
works as expected
so it seems the issue is when backslash is the first non-blank character
tar, on the first load reset the tar completion script
so on first keystroke, the completion happen normally but fail the second time until a new script call completion loader
I was trying to use gradle with fzf-obc, but it turns out to be not so convenient due to gradle completion list containing task descriptions, not just their names. As a result, both name and description end up on the command line, which is undesirable.
To test, install gradle (I have version 6.0), gradle-completion, and for testing purposes create a new directory and create a build.gradle file there, with contents from this gist, for example.
Type gradle <TAB>
(with fzf-obc activated), and the completion list is shown. It takes several seconds when done for the first time, after that it will work instantaneous as gradle-completion has a cache.
Here's an example item from the completion list:
wrapper - Generates Gradle wrapper files.
If it's selected, the whole thing is appended to the command line, while it would be desirable to have only wrapper
on the command line.
If it would be possible to be able to specify some post-processing step for a particular completion command, a function could be set up that strips the whitespace, the dash and the description.
Maybe it's already a feature? Or could be a new feature request. Or maybe you have better ideas?
Thanks for looking into it!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.