junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.36k stars 2.4k forks source link

Feature Request fasd integration #130

Closed wikimatze closed 9 years ago

wikimatze commented 9 years ago

I'm very happy with your plugin, is it possible to add the same functionality which is described under https://github.com/clvv/fasd - so when I press d it will show me the entries of my most typed in commands?

Thanks for the awesome work that went into this plugin.

junegunn commented 9 years ago

Hi, I'm not sure what your request is.

Is it

  1. Integration with fasd
  2. or, is it writing a fasd-like feature using fzf?

it will show me the entries of my most typed in commands

This also confuses me a little, as fasd does not seem to have an option to show the most used command, but only files and directories.

If what you want is some kind of shell function for launching fzf finder for most used commands, I can think of something like the following.

eval $(HISTTIMEFORMAT= history | sed 's/^[0-9 ]*//' | sort | uniq -c | sort -n | fzf +s --nth 2..,1 | sed 's/^[0-9 ]*//')

But note that this only considers the number of occurrences and not the recency of the commands.

wikimatze commented 9 years ago

It is point 2. writing a fasd-like feature using fzf. So I want to have the recency of mos visited directories. Here is a small example. If I type in d I get:

1          /home/wm/.config
1          /home/wm/git-repositories/padrinorb-website/contribute
1          /home/wm/git-repositories/padrinorb-website/_includes/css
1          /home/wm/ownCloud/blog-wikimatze/_drafts
1          /home/wm/ownCloud/blog-wikimatze/js/libs/ui
1          /home/wm/ownCloud/git-repositories/job-vacancy/spec
1          /mnt/sdc1
1          /usr/share/texmf/tex/latex
2          /home/wm
2          /home/wm/aa/files
2          /home/wm/bitbucket/presentations/.tmp
2          /home/wm/git-repositories/ember-app/.git
2          /home/wm/git-repositories/padrinorb-website/_includes
2          /home/wm/git-repositories/padrinorb-website/_includes/js
2          /home/wm/git-repositories/padrinorb-website/js
2          /home/wm/.local/share/Trash/files
2          /home/wm/ownCloud/archive
2          /home/wm/ownCloud/blog-wikimatze/js/libs
2          /home/wm/ownCloud/vimberlin.de/_drafts
2          /home/wm/.vim/plugged/AutoTag
2          /home/wm/.vim/plugged/blockit
2          /home/wm/.vim/plugged/calendar-vim
2          /home/wm/.vim/plugged/delimitMate
2          /home/wm/.vim/plugged/github-issues.vim
2          /home/wm/.vim/plugged/gitv
2          /home/wm/.vim/plugged/neocomplete.vim
2          /home/wm/.vim/plugged/neosnippet.vim
2          /home/wm/.vim/plugged/nerdtree
2          /home/wm/.vim/plugged/nyancat-vim
2          /home/wm/.vim/plugged/open-browser.vim
2          /home/wm/.vim/plugged/ri.vim/plugin
2          /home/wm/.vim/plugged/syntastic
2          /home/wm/.vim/plugged/tcomment_vim
2          /home/wm/.vim/plugged/tmux-complete.vim
2          /home/wm/.vim/plugged/tocdown
2          /home/wm/.vim/plugged/undotree
2          /home/wm/.vim/plugged/vim-airline
2          /home/wm/.vim/plugged/vim-easy-align
2          /home/wm/.vim/plugged/vim-easygrep
2          /home/wm/.vim/plugged/vim-endwise
2          /home/wm/.vim/plugged/vim-fugitive
2          /home/wm/.vim/plugged/vim-gnupg
2          /home/wm/.vim/plugged/vim-latex-folding
2          /home/wm/.vim/plugged/vim-lexical/plugin
2          /home/wm/.vim/plugged/vim-markdown-folding
2          /home/wm/.vim/plugged/vim-merginal
2          /home/wm/.vim/plugged/vim-misc
2          /home/wm/.vim/plugged/vim-move
2          /home/wm/.vim/plugged/vim-notes
2          /home/wm/.vim/plugged/vim-polyglot
2          /home/wm/.vim/plugged/vim-ruby
2          /home/wm/.vim/plugged/vim-testkey
2          /home/wm/.vim/plugged/vim-tmux-navigator
2          /home/wm/.vim/plugged/vim-webdevicons
2          /home/wm/.vim/plugged/vim-wordy
2          /home/wm/.zsh
2          /usr/include
4          /home/wm/Audiobooks
4          /home/wm/code
4          /home/wm/Documents
4          /home/wm/Downloads/install_flash_player_11_linux.x86_64/usr
4          /home/wm/Downloads/install_flash_player_11_linux.x86_64/usr/bin
4          /home/wm/Downloads/install_flash_player_11_linux.x86_64/usr/lib
4          /home/wm/Downloads/install_flash_player_11_linux.x86_64/usr/lib64
4          /home/wm/Downloads/install_flash_player_11_linux.x86_64/usr/share
4          /home/wm/latex
4          /home/wm/learn_ruby
4          /home/wm/lernhelfer
4          /home/wm/Music
4          /home/wm/node_modules
4          /home/wm/Pictures
4          /home/wm/Podcasts
4          /home/wm/Public
4          /home/wm/src
4          /home/wm/Templates
4          /home/wm/tmp
4          /home/wm/Videos
4          /home/wm/.vim/autoload
4          /home/wm/.vim/plugged/ri.vim/plugin/ri_vim_cache
4          /home/wm/VirtualBox VMs
4          /usr
5          /home/wm/ownCloud/latex/projekte/git
5          /home/wm/ownCloud/latex/projekte/kuendigungen
5          /home/wm/ownCloud/latex/projekte/kuendigungen/hanna_bildungsmentoren.tex
5          /usr/lib/mozilla/plugins
10         /home/wm/bin
10         /home/wm/.fzf
10         /home/wm/test
2.5        /home/wm/git-repositories/myapp
2.5        /home/wm/.irssi
2.5        /home/wm/ownCloud/bitbucket/presentations
2.5        /home/wm/ownCloud/blog-wikimatze/js
2.5        /home/wm/ownCloud/padrino/manuscript/images
2.5        /home/wm/ownCloud/vimberlin.de/_posts
2.5        /home/wm/.vim/plugged/unite-help
2.5        /home/wm/.vim/plugged/unite-radio.vim
2.5        /home/wm/.vim/settings
2.5        /usr/sbin
2.9        /home/wm/ownCloud/latex/projekte/java
2.9        /home/wm/.vim/plugged/unite-tag
11.6       /home/wm/bitbucket
208.96     /home/wm/.vim
34.298     /home/wm/.vim/plugged
4.7887     /home/wm/.vim/plugged/vim-surround
47.978     /home/wm/git-repositories
5.7549     /home/wm/ownCloud/vimberlin.de/_site
10.3952    /home/wm/ownCloud/latex/projekte
11.6549    /home/wm/ownCloud/dotfiles/zsh/completions
12.1947    /home/wm/ownCloud/latex/projekte/briefe/senatsverwaltung
12.3246    /home/wm/git-repositories/ember-app
126.035    /home/wm/ownCloud/blog-wikimatze
12.9793    /home/wm/aa
13.1536    /home/wm/Downloads/install_flash_player_11_linux.x86_64
13.4577    /home/wm/.vim/plugged/ri.vim
13.5644    /home/wm/ownCloud/padrinobook-website
14.0008    /home/wm/ownCloud/dotfiles/tmuxifier_layouts
14.0457    /home/wm/ownCloud/dotfiles/irssi
15.1522    /home/wm/.vim/plugged/vim-lexical
15.3378    /home/wm/Dropbox
159.249    /home/wm/ownCloud/dotfiles/scripts
18.2795    /home/wm/ownCloud/latex/projekte/ruby
19.1548    /home/wm/.vim/plugged/vimproc.vim
20.7905    /home/wm/Desktop
22.3022    /home/wm/ownCloud/latex/vorlagen/cv
22.3022    /home/wm/.vim/plugged/vim-litecorrect
23.0196    /home/wm/ownCloud/notes
30.6012    /tmp
3.24483    /home/wm/ownCloud/dotfiles/scripts/archive
3.24483    /home/wm/ownCloud/padrinobook-website/js
34.7645    /home/wm/ownCloud/latex/projekte/javascript
3.55301    /home/wm/.vim/colors
3.55301    /usr/local/bin
38.1748    /home/wm/bitbucket/presentations
3.83446    /home/wm/.vim/functions
3.83446    /media/wm
4.09525    /home/wm/ownCloud/git-repositories
4.09525    /home/wm/ownCloud/padrino
4.33944    /home/wm/.vim/plugged/unite.vim
44.8636    /home/wm/ownCloud/git-repositories/job-vacancy
46.9628    /home/wm/ownCloud
48.0228    /home/wm/ownCloud/vimberlin.de
4.99752    /home/wm/.ssh
55.0878    /home/wm/git-repositories/padrinorb-website
5.57555    /home/wm/.vim/thesaurus
60.1456    /home/wm/ownCloud/dotfiles
6.48966    /home/wm/ownCloud/latex/projekte/briefe
7.02285    /home/wm/ownCloud/dotfiles/zsh
70.4552    /home/wm/ownCloud/padrino/manuscript
7.10602    /home/wm/ownCloud/latex
71.8072    /home/wm/Downloads
7.96539    /home/wm/git-repositories/vim-webdevicons
8.09093    /home/wm/ownCloud/dotfiles/zsh/lib
9.78032    /home/wm/git-repositories/padrino-new-web

When I type in d conf<Tab> I get the first match /home/wm/git-repositories/vim-webdevicons (7.96539), then /home/wm/.vim/plugged/vim-webdevicons (2), then /home/wm/git-repositories/padrinorb-website/contribute (1), and finally /home/wm/.config (1).

Bests

Matthias

junegunn commented 9 years ago

I see. But fzf is just a simple filter, like grep, that you can use it to build larger concepts. Implementing fasd-like "frecency" concept is I believe beyond the scope of this project. But I'd love to hear about it when someone comes up with such a solution which utilizes fzf.

Extending (not replacing) fasd with fzf seems like a better solution to me.

fd() {
  local DIR
  DIR=$(d | fzf +s +m) && cd $(sed 's/^[0-9.]* *//' <<< "$DIR")
}

Thanks!

wikimatze commented 9 years ago

Agree, I will try your solution.

junegunn commented 9 years ago

Okay, also check out z-integration section in wiki. https://github.com/junegunn/fzf/wiki/Examples#z

wikimatze commented 9 years ago

Works very nice, thanks for it. Maybe it's better to put this command as well in the README.

junegunn commented 9 years ago

We have migrated most of the examples on the README page to the wiki pages. Please note that anyone can edit those pages. If you come up with a useful one that you want to share with the others, feel free to update the page. Thanks.