Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6470817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:09:15+00:00 2026-05-25T06:09:15+00:00

Has anyone implemented the equivalent behavior of bash’s ‘cdpath’ in Powershell?

  • 0

Has anyone implemented the equivalent behavior of bash’s ‘cdpath’ in Powershell?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:09:15+00:00Added an answer on May 25, 2026 at 6:09 am

    Did not know about CDPATH before. Good to know. I whipped up the below for Powershell:

    function cd2 {
        param($path)
        if(-not $path){return;}
    
        if((test-path $path) -or (-not $env:CDPATH)){
            Set-Location $path
            return
        }
        $cdpath = $env:CDPATH.split(";") | % { $ExecutionContext.InvokeCommand.ExpandString($_) }
        $npath = ""
        foreach($p in $cdpath){
            $tpath = join-path $p $path
            if(test-path $tpath){$npath = $tpath; break;}
        }
        if($npath){
            #write-host -fore yellow "Using CDPATH"
            Set-Location $npath
            return
        }
    
        set-location $path
    
    }
    

    It will not be perfect, but works in the expected way. You can extend it I guess. Add it to your profile. If needed, also add an alias like so:

    set-alias -Name cd -value cd2 -Option AllScope
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone implemented the Enterprise Library VAB along wtih Code Contracts in .NET 4.0?
Are there any open-source compression/decomp libraries available for Ruby? Has anyone implemented LZW? Or,
Has anyone successfully implemented a Java based solution that uses Microsoft SQL Server 2005
Has anyone implemented John Resig's micro-templating in production code? In particular I'd like to
Has anyone implemented facebook Like on iPhone/iPad? I've done general Facebook Connect implementation before,
Silverlight 2 is missing the unload event for a UserControl. Has anyone implemented a
Has anyone implemented their own AdminSite? How easy/hard was the basic implementation? I'm in
Possible Duplicate: android steganography Has anyone implemented steganography on android? Can anyone post sample
Has anyone implemented the Butterworth filter in objective c? I need to implement this
Has anyone implemented Active Directory verification instead of SQL Server with this framework? Where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.