{"id":28281984,"url":"https://github.com/lexborisoff/switch-dir","last_synced_at":"2026-02-23T23:35:16.967Z","repository":{"id":274356528,"uuid":"920254697","full_name":"LexBorisoff/switch-dir","owner":"LexBorisoff","description":"Fast and interactive navigation between directories","archived":false,"fork":false,"pushed_at":"2025-08-04T03:22:32.000Z","size":5327,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-11-27T10:52:50.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LexBorisoff.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,"zenodo":null}},"created_at":"2025-01-21T20:36:46.000Z","updated_at":"2025-08-04T03:22:08.000Z","dependencies_parsed_at":"2025-06-17T00:32:37.361Z","dependency_job_id":"334396fd-7bf5-49fd-99aa-0347f5df3c8c","html_url":"https://github.com/LexBorisoff/switch-dir","commit_stats":null,"previous_names":["lexborisoff/switch-dir"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/LexBorisoff/switch-dir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LexBorisoff%2Fswitch-dir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LexBorisoff%2Fswitch-dir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LexBorisoff%2Fswitch-dir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LexBorisoff%2Fswitch-dir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LexBorisoff","download_url":"https://codeload.github.com/LexBorisoff/switch-dir/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LexBorisoff%2Fswitch-dir/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29760721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T21:02:23.375Z","status":"ssl_error","status_checked_at":"2026-02-23T20:58:31.539Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-05-21T12:14:16.803Z","updated_at":"2026-02-23T23:35:16.955Z","avatar_url":"https://github.com/LexBorisoff.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `switch-dir`\n\n![Build](https://img.shields.io/github/actions/workflow/status/LexBorisoff/switch-dir/release.yml)\n![NPM Version](https://img.shields.io/npm/v/switch-dir)\n\nCLI for fast and interactive navigation between directories.\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Arguments](#arguments)\n  - [Ambiguous arguments](#ambiguous-arguments)\n  - [Interactive mode](#interactive-mode)\n  - [Starting path](#starting-path)\n- [Portals](#portals)\n  - [List portals](#list-portals)\n  - [Add a new portal](#add-a-new-portal)\n  - [Delete portals](#delete-portals)\n\n## Installation\n\n**Step 1**. Run the following command using **_npx_** from any directory.\n\n```bash\nnpx switch-dir\n```\n\n**Step 2**. Follow the prompts to set up the command name.\n\n**Step 3**. Once the installation process is complete, add the following lines to your shell configuration file.\n\n- For POSIX-compatible shells like bash or zsh\n\n```bash\n# ~/.bashrc or ~/.zshrc\n\nif test -f ~/.switch-dir/start.sh; then\n  . ~/.switch-dir/start.sh\nfi\n```\n\n- For PowerShell\n\n```powershell\n# C:\\Program Files\\PowerShell\\7\\profile.ps1\n\nif (Test-Path -Path \"$env:HOMEPATH\\.switch-dir\\bin\") {\n  $env:Path = \"$env:HOMEPATH\\.switch-dir\\bin;$env:Path\"\n}\n```\n\n\u003e 💡 To get the path of your PowerShell configuration file, type `$PROFILE.` and tab through the available options to choose the necessary profile.\n\n**Step 4**. Restart your shell. The command should now be available.\n\n### How it works\n\nThe installation process creates a `~/.switch-dir` directory where it installs the **_core library_** and creates a **_shell script_** that acts as the program's main entry point. For shells like bash and zsh, the script contains a function that allows changing directories within the shell. To have this function available as a command, the script must be sourced on each shell startup, which is handled in the `start.sh` script. For PowerShell, the script's directory (`bin`) is added to your PATH, making the script accessible from anywhere in the shell. By giving the script (or function) a name that you prefer (or sticking to the default), you control how to invoke the program.\n\n### Renaming the command\n\nYou can rename the command later by providing the `--rename` option with the new command name. If the name is not provided, you will be prompted to enter one. For POSIX shells, you will need to restart the shell after you've renamed the command.\n\n```bash\nsd --rename \u003cnew-name\u003e\n```\n\n\u003e 📚 All following examples will assume the command name is `sd`\n\n## Usage\n\nTo interactively select a directory to switch to, run the command you created during the installation. Calling without any arguments or options will display all available directories in the current directory.\n\nFor example:\n\n```bash\nsd\n```\n\n```text\napp\n├── components\n│   ├── button\n│   ├── card\n│   ├── modal\n│   └── navbar\n│       ├── link\n│       └── menu\n├── config\n│   ├── dev\n│   ├── prod\n│   └── test\n└── controllers\n    ├── auth\n    │   ├── login\n    │   └── register\n    └── user\n```\n\n\u003cimg src=\"https://github.com/LexBorisoff/switch-dir/blob/main/media/usage.gif?raw=true\" alt=\"usage example\" width=\"1000\" /\u003e\n\n### Arguments\n\nSupplying command arguments will build the final path by matching each argument with a directory.\n\nFor example, to navigate to `~/dev/app/components/navbar/link/` you could run the command from the home `~` directory as follows:\n\n```bash\nsd dev app comp nav link\n```\n\n\u003cimg src=\"https://github.com/LexBorisoff/switch-dir/blob/main/media/arguments.gif?raw=true\" alt=\"usage example\" width=\"1000\" /\u003e\n\n### Ambiguous arguments\n\nWhen multiple directories match a given argument, the CLI will prompt you to manually resolve this ambiguity by selecting the desired directory.\n\n\u003cimg src=\"https://github.com/LexBorisoff/switch-dir/blob/main/media/multiple-matches.gif?raw=true\" alt=\"usage example\" width=\"1000\" /\u003e\n\n\u003e 💡 When multiple directories match an argument but there is an exact match, it will be chosen automatically.\n\n### Interactive mode\n\nBy default, providing command arguments or using the [`--root` option](#starting-path) or the [`--portal` option](#portals) will navigate to the constructed path without displaying the selection prompt. You can change this behavior by providing the `--interactive` or `-i` flag which allows you to continue the directory search by using the selection prompt.\n\nFor example:\n\n```bash\nsd dev app conf prod -i\n```\n\n\u003e 👆 constructs the path based on the provided arguments and prompts you to select directories from there\n\n### Starting path\n\nTo start navigation from a specific path rather than the current directory, you can provide the `--root` or `-r` option followed by the desired path. If there are no [command arguments](#arguments), it will simply switch to that path.\n\nFor example:\n\n```bash\nsd --root ~/dev\n```\n\n\u003e 👆 navigates to the `~/dev` directory\n\n```bash\nsd app conf prod --root ~/dev\n```\n\n\u003e 👆 navigates to `~/dev/app/config/prod` from whatever directory you are in\n\n## Portals\n\nPortals are a way to quickly switch to saved directories using portal names instead of full paths. They function similarly to the `--root` option but accept a name value rather than a directory path. If no name is provided, you will be prompted to select one.\n\nTo navigate to a saved portal, use the `--portal` or `-p` option. For example:\n\n```bash\nsd --portal\n```\n\n\u003e 👆 displays the selection prompt with all available portals\n\nTo navigate to a portal named `app` which points to the `~/dev/app` path, you can run the following command:\n\n```bash\nsd --portal app\n```\n\nYou can also specify a partial name of the portal and it will still be matched. If there are multiple or no matches, you will be prompted to select the desired portal - just like with the directory selection (similarly, if there is an exact match, it will be chosen automatically).\n\n```bash\nsd -p a\n```\n\n### Add a new portal\n\nTo save a directory path as a portal, use the `--add` or `-a` option with the value of the portal's path. You will then be prompted to create the portal name.\n\nFor example:\n\n```bash\nsd --add .\n```\n\n\u003e 👆 saves the current directory path and displays a prompt to create the portal name\n\n### List portals\n\nTo list the saved portals, use the `--list` or `-l` flag.\n\n```bash\nsd --list\n```\n\n### Delete portals\n\nTo delete one or more portals, use the `--delete` or `-d` flag.\n\n```bash\nsd --delete\n```\n\n#### Prune portals\n\nIf there are portal paths that are unreachable (for example, a directory was deleted or renamed), the delete option will ask if you want to prune them, i.e. to delete all unreachable portals.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexborisoff%2Fswitch-dir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flexborisoff%2Fswitch-dir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexborisoff%2Fswitch-dir/lists"}