The PowerShell goto
function provides an easy way to manage and navigate to your frequently used directories using simple aliases. This function mimics the behavior of the Unix goto
command, making it easier to switch directories in a more organized manner.
- Register Directory Aliases: Quickly save directory paths with memorable aliases.
- Navigate with Aliases: Jump to any registered directory using its alias.
- List Aliases: View all currently registered aliases and their paths.
- Unregister Aliases: Remove aliases you no longer need.
- Expand Aliases: Display the full path of a registered alias.
- Cleanup Aliases: Remove aliases pointing to non-existent directories.
- Push Directory onto Stack: Save your current directory before moving to another.
- Pop Directory from Stack: Return to the most recently saved directory.
- Auto-update functionality: Automatically check for and apply updates to the goto function.
- Fuzzy Matching: Find aliases even with partial or misspelled input.
Installation
To install the Goto module from PowerShell Gallery, run the following command in your PowerShell session:
Install-Module -Name Goto -Scope CurrentUser
If you want to install for all users on the system, run PowerShell as Administrator and use:
Install-Module -Name Goto -Scope AllUsers
After installation, the module will automatically set up the necessary environment and update your PowerShell profile.
After installation, import the module:
Import-Module Goto
For automatic importing, this line will be added to your PowerShell profile during installation.
To save a directory path under a memorable alias:
goto -r <alias> <path>
To change to a directory associated with an alias:
goto <alias>
To list all registered aliases and their associated paths:
goto -l
To remove a previously registered alias:
goto -u <alias>
To see the full directory path associated with an alias:
goto -x <alias>
To remove all aliases pointing to non-existent directories:
goto -c
To save your current directory and navigate to another:
goto -p <alias>
To return to the directory saved before the last navigation:
goto -o
To check for updates and apply the latest version of the goto function:
goto -update
Here are some practical examples to demonstrate how to use the goto function:
- Setting up a workspace:
goto -r work "C:\Users\UserName\Documents\Work"
goto work
- Switching between projects quickly:
# Register a project directory and a common resources directory
goto -r proj "D:\Projects\CurrentProject"
goto -r resources "D:\Resources"
# Navigate to the project
goto proj
# Assume you are now working within the project and need to check something in resources
# Push the current project directory onto the stack and navigate to resources
goto -p resources
# After finishing up in the resources directory, pop the stack to return to the project
goto -o
If you encounter any issues or have suggestions for improvements, please open an issue on this GitHub repository.
Contributions are welcome! Please feel free to submit pull requests with improvements to the scripts or documentation.
This project is licensed under the MIT License - see the LICENSE file for details.