wiki/_next/data/Ie9t5zutrXP6Of75Cb5xF/cli.fzf.json
2022-07-29 15:41:17 +00:00

1 line
11 KiB
JSON

{"pageProps":{"metadata":{"date":"\"2021-05-31 23:08:57 +08:00\"","date_modified":"\"2021-07-27 12:38:25 +08:00\"","language":"en","source":""},"title":"Command line: fzf","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"options"},"children":[{"type":"text","value":"Options"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.fzf#options"},"children":[{"type":"text","value":"Options"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"examples"},"children":[{"type":"text","value":"Examples"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.fzf#examples"},"children":[{"type":"text","value":"Examples"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"basic-command-line-file-selection"},"children":[{"type":"text","value":"Basic command-line file selection"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.fzf#basic-command-line-file-selection"},"children":[{"type":"text","value":"Basic command-line file selection"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"quick-manual-page-selection"},"children":[{"type":"text","value":"Quick manual page selection"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.fzf#quick-manual-page-selection"},"children":[{"type":"text","value":"Quick manual page selection"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"goto-directory-with-fzf-and-bash"},"children":[{"type":"text","value":"Goto directory with fzf and Bash"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.fzf#goto-directory-with-fzf-and-bash"},"children":[{"type":"text","value":"Goto directory with fzf and Bash"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"package-selection-in-arch-linux"},"children":[{"type":"text","value":"Package selection in Arch Linux"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.fzf#package-selection-in-arch-linux"},"children":[{"type":"text","value":"Package selection in Arch Linux"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"create-an-interactive-tldr-list"},"children":[{"type":"text","value":"Create an interactive tldr list"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.fzf#create-an-interactive-tldr-list"},"children":[{"type":"text","value":"Create an interactive tldr list"}]}]}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The family's favorite fuzzy finder.\nBasically, it takes a list then create an interface out of it.\nNot only it is easy to use and very flexible but also very configurable with the options to let you choose the keybindings and the previewer among other things.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"options"},"children":[{"type":"text","value":"Options"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-m, --multi"}]},{"type":"text","value":" - enables multiple selection; by default, the keybinding to select is "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"Tab"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-p, --prompt"}]},{"type":"text","value":" - display the prompt message\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"--disabled"}]},{"type":"text","value":" - disable the search making fzf essentially a selection interface\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"--cycle"}]},{"type":"text","value":" - enables cyclic scrolling in the selection (it's annoying when it does not have those)\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":" If no input was passed, it will recursively list all of the files in the current directory.\n Pretty useful for a quick opening interface.\n"}]}]}]},{"type":"element","tagName":"h1","properties":{"id":"examples"},"children":[{"type":"text","value":"Examples"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"My favorite section where I get to show off some scripts featuring the star of the show.\nAnd also this is where everyone is going to go first.\n"}]},{"type":"element","tagName":"h2","properties":{"id":"basic-command-line-file-selection"},"children":[{"type":"text","value":"Basic command-line file selection"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"fzf | xargs xdg-open\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"quick-manual-page-selection"},"children":[{"type":"text","value":"Quick manual page selection"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"apropos . \\\n | fzf --multi --prompt \"Choose manual(s) to open > \" \\\n | awk '{ print $1 \".\" gensub(/[()]/, \"\", \"g\", $2) }' \\\n | xargs man\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Since a manual page can have the same title in different sections (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"tput.1"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"tput.1p"}]},{"type":"text","value":"), it is necessary to extract the sections.\n"}]},{"type":"element","tagName":"h2","properties":{"id":"goto-directory-with-fzf-and-bash"},"children":[{"type":"text","value":"Goto directory with fzf and Bash"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With my favorite "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"find"}]},{"type":"text","value":" replacement, "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/sharkdp/fd"},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"fd"}]}]},{"type":"text","value":".\nIt's a Bash function since "},{"type":"element","tagName":"a","properties":{"href":"https://stackoverflow.com/a/255415"},"children":[{"type":"text","value":"you can't propagate directory changes with a script"}]},{"type":"text","value":".\nJust have to put it somewhere in your configuration.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"function fzf-cd() {\n local dir=${1:-$(pwd)}\n local dest=$(fd --type directory --hidden --base-directory \"$dir\" --follow | fzf --prompt \"Where to go? > \")\n [[ $dest ]] && cd \"$(realpath --logical \"$dir\")/$dest\"\n}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Even better when you bind it with a keyboard shortcut (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"bind '\"\\C-f\":'fzf-cd\\n\"'"}]},{"type":"text","value":" on your Bash config).\n"}]},{"type":"element","tagName":"h2","properties":{"id":"package-selection-in-arch-linux"},"children":[{"type":"text","value":"Package selection in Arch Linux"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Vanilla Arch, if that matters.\nYou can do this on other operating systems as long as their package manager lets you list all of the packages either from your local database or from a remote server.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"pacman -S --list --quiet \\\n | fzf --multi --prompt \"Install package(s) > \" \\\n | xargs doas pacman -S --noconfirm\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"create-an-interactive-tldr-list"},"children":[{"type":"text","value":"Create an interactive tldr list"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Have a "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/tldr-pages/tldr/wiki/tldr-pages-clients"},"children":[{"type":"text","value":"tldr client"}]},{"type":"text","value":" (e.g., tealdeer) and "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/sharkdp/bat"},"children":[{"type":"text","value":"bat"}]},{"type":"text","value":" installed.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"tldr --list \\\n | fzf --multi \\\n | xargs --replace=\"{}\" tldr {} \\\n | bat\n"}]}]}]},"backlinks":[{"path":"/cli.borg","title":"Command line: BorgBackup"},{"path":"/cli.flatpak","title":"Command line: Flatpak"},{"path":"/cli.pacman","title":"Command line: pacman"},{"path":"/cli.podman","title":"Command line: Podman"}]},"__N_SSG":true}