npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

switch-dir

v1.0.2

Published

CLI for fast and interactive navigation between directories

Downloads

28

Readme

switch-dir

Build NPM Version

CLI for fast and interactive navigation between directories.

Installation

Step 1. Run the following command using npx from any directory.

npx switch-dir

Step 2. Follow the prompts to set up the command name.

Step 3. Once the installation process is complete, add the following lines to your shell configuration file.

  • For POSIX-compatible shells like bash or zsh
# ~/.bashrc or ~/.zshrc

if test -f ~/.switch-dir/start.sh; then
  . ~/.switch-dir/start.sh
fi
  • For PowerShell
# C:\Program Files\PowerShell\7\profile.ps1

if (Test-Path -Path "$env:HOMEPATH\.switch-dir\bin") {
  $env:Path = "$env:HOMEPATH\.switch-dir\bin;$env:Path"
}

💡 To get the path of your PowerShell configuration file, type $PROFILE. and tab through the available options to choose the necessary profile.

Step 4. Restart your shell. The command should now be available.

How it works

The 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.

Renaming the command

You 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.

sd --rename <new-name>

📚 All following examples will assume the command name is sd

Usage

To 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.

For example:

sd
app
├── components
│   ├── button
│   ├── card
│   ├── modal
│   └── navbar
│       ├── link
│       └── menu
├── config
│   ├── dev
│   ├── prod
│   └── test
└── controllers
    ├── auth
    │   ├── login
    │   └── register
    └── user

Arguments

Supplying command arguments will build the final path by matching each argument with a directory.

For example, to navigate to ~/dev/app/components/navbar/link/ you could run the command from the home ~ directory as follows:

sd dev app comp nav link

Ambiguous arguments

When multiple directories match a given argument, the CLI will prompt you to manually resolve this ambiguity by selecting the desired directory.

💡 When multiple directories match an argument but there is an exact match, it will be chosen automatically.

Interactive mode

By default, providing command arguments or using the --root option or the --portal option 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.

For example:

sd dev app conf prod -i

👆 constructs the path based on the provided arguments and prompts you to select directories from there

Starting path

To 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, it will simply switch to that path.

For example:

sd --root ~/dev

👆 navigates to the ~/dev directory

sd app conf prod --root ~/dev

👆 navigates to ~/dev/app/config/prod from whatever directory you are in

Portals

Portals 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.

To navigate to a saved portal, use the --portal or -p option. For example:

sd --portal

👆 displays the selection prompt with all available portals

To navigate to a portal named app which points to the ~/dev/app path, you can run the following command:

sd --portal app

You 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).

sd -p a

Add a new portal

To 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.

For example:

sd --add .

👆 saves the current directory path and displays a prompt to create the portal name

List portals

To list the saved portals, use the --list or -l flag.

sd --list

Delete portals

To delete one or more portals, use the --delete or -d flag.

sd --delete

Prune portals

If 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.