{"id":16345374,"url":"https://github.com/knl/rh","last_synced_at":"2025-03-23T00:32:43.864Z","repository":{"id":87827645,"uuid":"177119495","full_name":"knl/rh","owner":"knl","description":"A hierarchy aware `cd` command for easier navigation to your repositories","archived":false,"fork":false,"pushed_at":"2020-03-22T23:40:40.000Z","size":27,"stargazers_count":10,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T19:54:13.180Z","etag":null,"topics":["autojump","bash","cd","fish-shell","fuzzy","lua","powershell","shell","zsh","zsh-plugin"],"latest_commit_sha":null,"homepage":"","language":"Lua","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/knl.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-03-22T10:22:40.000Z","updated_at":"2021-09-20T19:37:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"ac68e90f-f850-4386-ac5e-24004d3442bb","html_url":"https://github.com/knl/rh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knl%2Frh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knl%2Frh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knl%2Frh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knl%2Frh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knl","download_url":"https://codeload.github.com/knl/rh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244257259,"owners_count":20424127,"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":["autojump","bash","cd","fish-shell","fuzzy","lua","powershell","shell","zsh","zsh-plugin"],"created_at":"2024-10-11T00:31:15.870Z","updated_at":"2025-03-23T00:32:43.819Z","avatar_url":"https://github.com/knl.png","language":"Lua","readme":"# rh.lua\n\nA [Go](https://golang.org) modules-like hierarchy aware `cd` command for\neasier navigation to your repositories.\n \nGo organizes modules based on `server/organization/repository` hierachy (for\nexample, `github.com/knl/rh`), which I liked a lot. `rh.lua` is a step toward\nhaving that structure with all repositories I keep on my machine, while making\nmy workflow as smooth as possible.\n\n`rh.lua` assumes that all the repositories are checked-out under a specific\numbrella folder in the filesystem, for example `~/work`. Under this\numbrella repository it would help navigate and maintain the repository hierarchy\nin the same manner as go modules, that is,\n`~/work/server/organization/repository`.\n\n`rh.lua` is fully implemented in lua in order to make it fast. `rh.lua` is\nheavily influenced and based on [`z.lua`](https://github.com/skywind3000/z.lua),\nfrom which it took all filesystem/datastore code.\n\n## Usage\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"600\" src=\"http://knezevic.ch/files/rh.svg\"\u003e\n\u003c/p\u003e\n\n* `rh.lua` lists all known repositories under predefined umbrella folder (that\n  is set during the installation).\n\n* `rh.lua [[server/]org/]repo` does a frecency search (a la `z.lua` and/or\n  `fasd_cd`) and searches for a repository whose name is partially matching\n  `repo`, for an org `org` and server `server`. If found, `cd`s to that folder.\n  If you omit both `server` and `org`, the search will be only over repository\n  names. If your search term is in form `org/repo`, it will try to match `org`\n  and then `repo` at respective positions. Similarly for the full blown term\n  `server/org/repo`. You could also use spaces instead of `/`.\n  If the best match matches the current folder, it will jump to the next\n  matching one.\n  \n  For example, `rh.lua pkg` will jump to `~/work/github.com/NixOs/nixpkgs`,\n  while `rh.lua f/pkg` will jump to `~/work/github.com/FreeBSD/pkg`.\n\n* `rh.lua [http|git|https]://server/org/repo` will look for a\n  `~/work/\u003cserver\u003e/\u003corg\u003e/\u003crepo\u003e` folder and `cd` to it. If the folder doesn't\n  exist, it will clone it with git and `cd` to it.\n\n* `rh.lua term\u003cTAB\u003e` will autocomplete based on `term`.\n\n## Dependencies\n\nApart from a working [lua](https://www.lua.org/) installation, `rh.lua` requires\neither `z.lua` or `fasd_cd` (for the latter, set `$_RH_DATA` to `~/.fasd`). \n\n## Installation\n\nCopy the `rh.lua` script to somewhere in the PATH.\n\n* Zsh Install:\n  Put something like this in your `.zshrc`:\n\n      eval \"$(lua /path/to/rh.lua --init zsh ~/work)\"\n\n  It can also be initialized from \"knl/rh\" with your zsh plugin\n  managers (antigen / oh-my-zsh). Just don't forget to set `$_RH_ROOT`.\n\n* Bash Install:\n  Put something like this in your `.bashrc`:\n\n      eval \"$(lua /path/to/rh.lua --init bash ~/work)\"\n\n* Posix Shell Install:\n  Put something like this in your `.profile`:\n\n      eval \"$(lua /path/to/rh.lua --init posix ~/work)\"\n\n* Fish Shell Install:\n  Put something like this in `~/.config/fish/conf.d/z.fish`:\n\n      source (lua /path/to/rh.lua --init fish ~/work | psub)\n\n  Fish version 2.4.0 or above is required.\n\n* Power Shell Install:\n  Put something like this in your `profile.ps1`:\n\n      iex ($(lua /path/to/rh.lua --init powershell) -join \"`n\")\n\n* Windows Install (with [Clink](https://mridgers.github.io/clink/)):\n    * Copy `rh.lua` and `rh.cmd` to clink's home directory\n    * Add clink's home to `%PATH%` (`rh.cmd` can be called anywhere)\n    * Ensure that \"lua\" can be called in `%PATH%`\n    * Ensure that \"lua\" can be called in %PATH%\n\n* Windows Cmder Install:\n    * Copy `rh.lua` and `rh.cmd` to `cmder/vendor`\n    * Add `cmder/vendor` to `%PATH%`\n    * Ensure that \"lua\" can be called in `%PATH%`\n\n## Configure\n\nThis is optional step, use it if you really need to.\n\n* Set `$_RH_CMD` in `.bashrc`/`.zshrc` to change the command (default `rh`).\n* Set `$_RH_DATA` in `.bashrc`/`.zshrc` to change the datafile (default `~/.zlua`).\n* Set `$_RH_ROOT` in `.bashrc`/`.zshrc` to change the store root (default `~/work`).\n\n## History\n\n- 1.0.0 (2019-03-22): First official release\n\n## FAQ\n\n### Why is it called `rh`?\n\nRepository Hierarchy.\n\n### Why did you write this in Lua, isn't Lua slow?\n\nLua is a great language and pretty fast at it. For example `z.lua` is faster\nthan other alternatives, even tho it code gets interpreted and requires loading\nof lua executable. Plus, basing the code on `z.lua` allows this gem to run on\nmany platforms.\n\n### OMG, why \u003e1000 LoC?\n\nMostly to make it self contained and avoid loading many modules. Everything sits\nin a single file.\n\n### How different is `rh.lua` from `z.lua`?\n\nFor the initial release, `git diff --stat -b` shows:\n\n     z.lua =\u003e ../../knl/rh/rh.lua | 1734 ++++++--------------------------------\n     1 file changed, 253 insertions(+), 1481 deletions(-)\n\nThis code is a modification of `z.lua` to support reading the same data file and\nhave all the supporting functions, however some parts were modified in order to\nhave the desired functionality.\n\n`rh.lua` will not update the data file, ever! It only reads from it and makes\ndecision where to jump.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknl%2Frh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknl%2Frh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknl%2Frh/lists"}