{"id":13998274,"url":"https://github.com/gazorby/fifc","last_synced_at":"2025-04-04T21:10:52.460Z","repository":{"id":41545494,"uuid":"509403265","full_name":"gazorby/fifc","owner":"gazorby","description":"🐠 Configurable fzf completions for fish shell","archived":false,"fork":false,"pushed_at":"2024-12-04T12:50:46.000Z","size":60016,"stargazers_count":189,"open_issues_count":21,"forks_count":15,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T20:11:43.316Z","etag":null,"topics":["cli","complete","completion","fish","fish-packages","fish-plugin","fish-shell","fisher","fuzzy-search","fzf","fzf-preview-pane","fzf-scripts","fzf-tab"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gazorby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-01T09:52:40.000Z","updated_at":"2025-03-27T13:59:40.000Z","dependencies_parsed_at":"2024-04-07T20:37:43.136Z","dependency_job_id":"8f053ffb-c8f3-484d-b9ac-953f7f23d505","html_url":"https://github.com/gazorby/fifc","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazorby%2Ffifc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazorby%2Ffifc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazorby%2Ffifc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazorby%2Ffifc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gazorby","download_url":"https://codeload.github.com/gazorby/fifc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249532,"owners_count":20908212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","complete","completion","fish","fish-packages","fish-plugin","fish-shell","fisher","fuzzy-search","fzf","fzf-preview-pane","fzf-scripts","fzf-tab"],"created_at":"2024-08-09T19:01:31.737Z","updated_at":"2025-04-04T21:10:52.440Z","avatar_url":"https://github.com/gazorby.png","language":"Shell","readme":"\u003cdiv align=\"center\"\u003e\n\n# fifc 🐠\n\n_fish fzf completions_\n\n[![CI](https://github.com/gazorby/fifc/actions/workflows/ci.yml/badge.svg)](https://github.com/gazorby/fifc/actions/workflows/ci.yml)\n\nfifc brings fzf powers on top of fish completion engine and allows customizable completion rules\n\n\u003c/div\u003e\n\n![gif usage](../assets/demo.gif)\n\n## ✅ Requirements\n\n- [fish](https://github.com/fish-shell/fish-shell) 3.4.0+\n\n## ✨ Features\n\n- Preview/open any file: text, image, gif, pdf, archive, binary (using external tools)\n- Preview/open command's man page\n- Preview/open function definitions\n- Preview/open full option description when completing commands\n- Recursively search for files and folders when completing paths (using [fd](https://github.com/sharkdp/fd))\n- Preview directory content\n- Preview process trees (using [procs](https://github.com/dalance/procs))\n- Modular: easily add your own completion rules\n- Properly handle paths with spaces (needs fish 3.4+)\n\n## 🚀 Install\n\n```fish\nfisher install gazorby/fifc\n```\n\n## 🔧 Usage\n\nYou only need to set one setting after install:\n\n```fish\nset -Ux fifc_editor \u003cyour-favorite-editor\u003e\n```\n\nAnd enjoy built-in completions!\n\nBy default fifc override `tab`, but you can assign another keybinding:\n\n```fish\n# Bind fzf completions to ctrl-x\nset -U fifc_keybinding \\cx\n```\n\nfifc can use modern tools if available:\n\n| Prefer                                           | Fallback to | Used for                                  | Custom options     |\n| ------------------------------------------------ | ----------- | ----------------------------------------- | ------------------ |\n| [bat](https://github.com/sharkdp/bat)            | cat         | Preview files                             | `$fifc_bat_opts`   |\n| [chafa](https://github.com/hpjansson/chafa)      | file        | Preview images, gif, pdf etc              | `$fifc_chafa_opts` |\n| [hexyl](https://github.com/sharkdp/hexyl)        | file        | Preview binaries                          | `$fifc_hexyl_opts` |\n| [fd](https://github.com/sharkdp/fd)              | find        | Complete paths                            | `$fifc_fd_opts`    |\n| [exa](https://github.com/ogham/exa)              | ls          | Preview directories                       | `$fifc_exa_opts`   |\n| [ripgrep](https://github.com/BurntSushi/ripgrep) | pcregrep    | Search options in man pages               | -                  |\n| [procs](https://github.com/dalance/procs)        | ps          | Complete processes and preview their tree | `$fifc_procs_opts` |\n| [broot](https://github.com/Canop/broot)          | -           | Explore directory trees                   | `$fifc_broot_opts` |\n\nCustom options can be added for any of the commands used by fifc using the variable mentioned in the above table.\n\nExample:\n\nShow line number when previewing files:\n\n- `set -U fifc_bat_opts --style=numbers`\n\nShow hidden file by default:\n\n- `set -U fifc_fd_opts --hidden`\n\n⚠️ Don't use quotes in variables, set them as a list: `set -U fifc_exa_opts --icons --tree`\n\n## 🛠️ Write your own rules\n\nCustom rules can easily be added using the `fifc` command. Actually, all builtin rules are added this way: see [conf.d/fifc.fish](https://github.com/gazorby/fifc/blob/52ff966511ea97ed7be79db469fe178784e22fd8/conf.d/fifc.fish)\n\nSee `fifc -h` for more details.\n\nBasically, a rule allows you to trigger some commands based on specific conditions.\n\nA condition can be either:\n\n- A regex that must match commandline before the cursor position\n- An arbitrary command that must exit with a non-zero status\n\nIf conditions are met, you can bind custom commands:\n\n- **preview:** Command used for fzf preview\n- **source:** Command that feeds fzf input\n- **open:** Command binded to `fifc_open_keybinding` (defaults to ctrl-o)\n\nAll commands have access to the following variable describing the completion context:\n\n| Variable           | Description                                                                                        | Command availability |\n| ------------------ | -------------------------------------------------------------------------------------------------- | -------------------- |\n| `fifc_candidate`   | Currently selected item in fzf                                                                     | all except source    |\n| `fifc_commandline` | Commandline part before the cursor position                                                        | all                  |\n| `fifc_token`       | Last token from the commandline                                                                    | all                  |\n| `fifc_group`       | Group to which fish suggestions belong (possible values: directories, files, options or processes) | all                  |\n| `fifc_extracted`   | Extracted string from the currently selected item using the `extracted` regex, if any              | all except source    |\n| `fifc_query`       | fzf query. On source command, it is the initial fzf query (passed through `--query` option)        | all                  |\n\n### **fifc_group** values\n\nfifc test completion items to set `fifc_group` with the following conditions:\n\n| Group       | Condition                                                    |\n| ----------- | ------------------------------------------------------------ |\n| directories | All completion items are directories                         |\n| files       | Items can be either files _or_ directories                   |\n| options     | All items match the following regex: `\\h+\\-+\\h*$`            |\n| processes   | All items match the following regex `^[0-9]+$` (list of PID) |\n\n### Matching order\n\nBy default, fifc evaluate all rules in the order in which they have been defined and stops at the first where all conditions are met.\nIt does this each time it has to resolve source, preview and open commands.\n\nTake the following scenario:\n\n```fish\n# Rule 1\nfifc -n 'test \"$fifc_group\" = files' -p 'bat $fifc_candidate'\n# Rule 2\nfifc -n 'string match \"*.json\" \"$fifc_candidate\"' -p 'bat -l json $fifc_candidate'\n```\n\nWhen completing path, `$fifc_group` will be set to \"files\" so the first rule will always be valid in that case, and the second one will never be reached.\n\nAnother example:\n\n```fish\n# Rule 1\nfifc --condition 'test \"$fifc_group\" = files' --preview 'bat $fifc_candidate'\n# Rule 2\nfifc --condition 'test \"$fifc_group\" = files' --source 'fd . --color=always --hidden $HOME'\n```\n\nHere, even if both rules have the same conditions, they won't interfere because fifc has to resolve source commands _before_ the preview commands, so order doesn't matter in this case.\n\n### Override builtin rules\n\nIf you want to write your own rule based on the same conditions as one of the built-in ones, you can use fifc `--order` option.\nIt tells fifc to evaluate the rule in a predefined order, so you can set it to 1 to make sure it will be evaluated first.\n\nWhen omitting the `--order`, the rule will be declared unordered and will be evaluated _after_ all other ordered rules, and all other unordered rules defined before.\n\nAll built-in rules are unordered.\n\n### Examples\n\nHere is how the built-in rule for file preview/open is implemented:\n\n```fish\nfifc \\\n    # If selected item is a file\n    -n 'test -f \"$fifc_candidate\"' \\\n    # bind `_fifc_preview_file` to preview command\n    -p _fifc_preview_file \\\n    # and `_fifc_preview_file` when pressing ctrl-o\n    -o _fifc_open_file\n```\n\nInteractively search packages in archlinux:\n\n```fish\nfifc \\\n    -r '^(pacman|paru)(\\\\h*\\\\-S)?\\\\h+' \\\n    -s 'pacman --color=always -Ss \"$fifc_token\" | string match -r \\'^[^\\\\h+].*\\'' \\\n    -e '.*/(.*?)\\\\h.*' \\\n    -f \"--query ''\" \\\n    -p 'pacman -Si \"$fifc_extracted\"'\n```\n\n![gif usage](../assets/pacman.gif)\n\nSearch patterns in files and preview matches when commandline starts with `**\u003cpattern\u003e` (using [ripgrep](https://github.com/burntsushi/ripgrep) and [batgrep](https://github.com/eth-p/bat-extras/blob/master/doc/batgrep.md#bat-extras-batgrep)):\n\n```fish\nfifc \\\n    -r '.*\\*{2}.*' \\\n    -s 'rg --hidden -l --no-messages (string match -r -g \\'.*\\*{2}(.*)\\' \"$fifc_commandline\")' \\\n    -p 'batgrep --color --paging=never (string match -r -g \\'.*\\*{2}(.*)\\' \"$fifc_commandline\") \"$fifc_candidate\"' \\\n    -f \"--query ''\" \\\n    -o 'batgrep --color (string match -r -g \\'.*\\*{2}(.*)\\' \"$fifc_commandline\") \"$fifc_candidate\" | less -R' \\\n    -O 1\n```\n\n![gif usage](../assets/batgrep.gif)\n\n## ❤️ Credits\n\nThanks [PatrickF1](https://github.com/PatrickF1) (and collaborators!), for the great [fzf.fish](https://github.com/PatrickF1/fzf.fish) plugin which inspired me for the command-based configuration, and from which I copied the ci workflow.\n\n## 📝 License\n\n[MIT](https://github.com/gazorby/fifc/blob/87c965fe42a5b2ddb6e0ea84871ca56651db1cb2/LICENSE)\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgazorby%2Ffifc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgazorby%2Ffifc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgazorby%2Ffifc/lists"}