Giving a go at FZF.

incedis

New Member
Joined
Jul 16, 2021
Messages
29
Reaction score
4
Credits
298
I have been using FZF for the past days with ZSH and VIM. Just to remind the context, I am the perfect Newbie. I get around with clear tutorial. The reason of wanting FZF, because I have thousands of Movies and Photos and was tired searching by hand.
As of now, everything is working perfectly but yet I can't seem to be able to make the default keybindings work for me.
Only Ctrl+r (searching ZSH history) works. Alt+c and Ctrl+t do not respond. If this help, I am getting "(eval):1: unknown file attribute"
 


f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
3,880
Reaction score
2,623
Credits
28,033
I would create an issue on their github project page since those are default key bindings and should work.
 
OP
I

incedis

New Member
Joined
Jul 16, 2021
Messages
29
Reaction score
4
Credits
298
I thought about it but I believe its not an issue with FZF. Its an issue with my brain being too small to comprehend FZF :(
If I had to take a guess, the issue probably is linked to using sudo or not. I have created the entire configuration file using user profile. To illustrate, when sourcing .vimrc (which contains the code for FZF and script linked to keybindings), it only works if I source it with user profile ($HOME/.vimrc). Doing it with sudo would not work. The root account has not say (sort of speak) on the .vimrc user profile. Does not sound technically correct but the result is there. Don't really know what to do next.

Code relating to keybinds
Code:
source "/home/beisiris/.fzf/shell/key-bindings.zsh"
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
3,880
Reaction score
2,623
Credits
28,033
According to the documentation the install script setups the default keybindings for your so that shouldn't be necessary. I installed fzf to try it but those default keybindings aren't working for me either something must be missing or not well documented. Do you have the fzf shell open? Also try installing it through your package manager instead of manually downloading it?
 
OP
I

incedis

New Member
Joined
Jul 16, 2021
Messages
29
Reaction score
4
Credits
298
1) Installed ZSH and VIM
2) Installed FZF plugin for ZSH
Code:
plugins=(git zsh-autosuggestions zsh-syntax-highlighting fzf-zsh-plugin)
3) Installed FZF plugin for Vim
Code:
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
 91   Plug 'junegunn/fzf.vim'
-----
  1. FZF shell opens up when Ctrl+r (looking through ZSH history)
  2. FZF shell does not open up when Ctrl+c (Find in current directory)
  3. FZF shell does not open up when Alt+c
  4. Code:
    find . | fzf
    works as expected.
 
OP
I

incedis

New Member
Joined
Jul 16, 2021
Messages
29
Reaction score
4
Credits
298
I made the keybinding Ctrl+f work inside VIM. A step forward :D
Code:
nnoremap <silent> <C-f> :Files<CR>
nnoremap <silent> <Leader>f :Ag<CR>

PS: Does not work inside ZSH. BTW, forgot to mention that I am also using "oh-my-zsh". Another vector for faults in the keybinding issue ?
 
OP
I

incedis

New Member
Joined
Jul 16, 2021
Messages
29
Reaction score
4
Credits
298
Found the answer.
Culprit -->
Code:
source $ZSH/oh-my-zsh.sh
: Inside .zshrc.
Solution: Move it around (trial and error) until the default keybindings work.. I have it now at the end. Last line..
All the default keybindings seem to work. I have no clue and won't even try explaining the reasoning behind this.
All points to this script doing things in the background that makes FZF break because I have a few lines of code that seem to be completely mute as well.
Code:
2 export FZF_TMUX=1
 export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null ||
 export FZF_CTRL_T_OPTS="--select-1 --exit-0"
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
3,880
Reaction score
2,623
Credits
28,033
Found the answer.
Code:
2 export FZF_TMUX=1
 export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null ||
 export FZF_CTRL_T_OPTS="--select-1 --exit-0"
Good job on finding the solution yourself! You didn't mentioned in your original post you were using tmux, I did come across that in the documentation.
 
OP
I

incedis

New Member
Joined
Jul 16, 2021
Messages
29
Reaction score
4
Credits
298
I am not using Tmux but read that you could still use the code to have a preview of the search.

fzf-tmux script

fzf-tmux script​


fzf-tmux is a bash script that opens fzf in a tmux pane.


# usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS]

# See available options
fzf-tmux --help

# select git branches in horizontal split below (15 lines)
git branch | fzf-tmux -d 15

# select multiple words in vertical split on the left (20% of screen width)
cat /usr/share/dict/words | fzf-tmux -l 20% --multi --reverse

It will still work even when you're not on tmux, silently ignoring -[pudlr] options, so you can invariably use fzf-tmux in your scripts.
 
Last edited:
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top