{"id":16936476,"url":"https://github.com/jonhoo/proximity-sort","last_synced_at":"2025-04-07T06:07:09.511Z","repository":{"id":41948227,"uuid":"149233219","full_name":"jonhoo/proximity-sort","owner":"jonhoo","description":"Simple command-line utility for sorting inputs by proximity to a path argument","archived":false,"fork":false,"pushed_at":"2023-02-11T20:11:42.000Z","size":78,"stargazers_count":123,"open_issues_count":1,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-31T04:07:33.630Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonhoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2018-09-18T05:24:03.000Z","updated_at":"2025-03-06T20:40:36.000Z","dependencies_parsed_at":"2024-10-27T00:58:07.574Z","dependency_job_id":null,"html_url":"https://github.com/jonhoo/proximity-sort","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fproximity-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fproximity-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fproximity-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fproximity-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonhoo","download_url":"https://codeload.github.com/jonhoo/proximity-sort/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601447,"owners_count":20964864,"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":[],"created_at":"2024-10-13T20:57:04.687Z","updated_at":"2025-04-07T06:07:09.487Z","avatar_url":"https://github.com/jonhoo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# proximity-sort\n\n[![Crates.io](https://img.shields.io/crates/v/proximity-sort.svg)](https://crates.io/crates/proximity-sort)\n[![Codecov](https://codecov.io/github/jonhoo/proximity-sort/coverage.svg?branch=master)](https://codecov.io/gh/jonhoo/proximity-sort)\n[![Dependency status](https://deps.rs/repo/github/jonhoo/proximity-sort/status.svg)](https://deps.rs/repo/github/jonhoo/proximity-sort)\n\nThis script provides a simple command-line utility that sorts its inputs\nby their path proximity to a given path. For example, for a path\n`foo/bar.txt`, the following input:\n\n```\nquox.txt\nfoo/bar.txt\nfoo/baz.txt\n```\n\nWould yield an output of:\n\n```\nfoo/bar.txt\nfoo/baz.txt\nquox.txt\n```\n\nThe lines are sorted by the number of leading path components shared\nbetween the input path and the provided path.\n\nThis program was primarily written to allow context-aware suggestions\nfor [`fzf`](https://github.com/junegunn/fzf) (requested in\n[junegunn/fzf.vim#360](https://github.com/junegunn/fzf.vim/issues/360)\nand\n[junegunn/fzf.vim#492](https://github.com/junegunn/fzf.vim/issues/492))\nwithout making modifications to `fzf` itself (see\n[junegunn/fzf#1380](https://github.com/junegunn/fzf/pull/1380)).\n\n## Installation\n\nIf you have [Rust installed](https://www.rust-lang.org/tools/install), you can\ninstall this with:\n\n```shell\ncargo install proximity-sort\n```\n\n## Usage\n\nIt can be used with `fzf` by running:\n\n```console\n$ fd -t f | proximity-sort path/to/file | fzf --tiebreak=index\n```\n\nAnd you can add it to your `.vimrc` with:\n\n```vim\nfunction! s:list_cmd()\n  let base = fnamemodify(expand('%'), ':h:.:S')\n  return base == '.' ? 'fd -t f' : printf('fd -t f | proximity-sort %s', expand('%'))\nendfunction\n\ncommand! -bang -nargs=? -complete=dir Files\n  \\ call fzf#vim#files(\u003cq-args\u003e, {'source': s:list_cmd(),\n  \\                               'options': '--tiebreak=index'}, \u003cbang\u003e0)\n```\n\nPaths of the same proximity are sorted alphabetically:\n\n```console\n$ echo \"banana\\napple/pie\\napple\" | proximity-sort . -s\n\u003e apple\n\u003e banana\n\u003e apple/pie\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Fproximity-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonhoo%2Fproximity-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Fproximity-sort/lists"}