-
-
Save johnnydecimal/cab3a02bce70dab7a4567d460d5c36e2 to your computer and use it in GitHub Desktop.
# https://johnnydecimal.com | |
cjdfunction() { | |
pushd ~/Dropbox/*/*/${1}* # ~/Dropbox is my root folder, change to suit yours. | |
} | |
export cjdfunction | |
alias cjd='cjdfunction' # Or any other alias you prefer. |
Is there any equivalent to this for powershell?
Hi! I know it's I little late, but I just found out the answer on Reddit . This does the trick:
function cdj
{
Param([string]$SearchString)
pushd ~\*\*\$SearchString*
}
Where ~
is your Windows User folder (you should change this to reflec your actual Johnny.Decimal root folder), and \*\*\
is used to tell PowerShell that it should go two directories deep to find the folder with the numbers you just typed in (32.01
, for example). The last *
after $SearchString
is indicating the computer to look for 32.01whatever
, since there shouldn't be two folders with the same code. Please remember to add that last *
, because the OP in Reddit forgot to add it in the final answer. This problem came up a little deeper into that thread and he never updated his main post, but kudos to them for figuring this one out.
EDIT: If this is your first time dealing with PS scripts, please remember that you'll need to put the script in a very specific folder. Open PowerShell and type cd $env:PSModulePath
to see where your Modules folders are. You can pick whichever you prefer, but I like the one that's in my home folder ~\Documents\WindowsPowerShell\Modules
. Inside this folder, you should create one called "cdj", and inside that you'll make your cdj.psm1
file, with the code I pasted above. Finally, you'll have to enable the execution of PS scripts with this simple command: set-executionpolicy unrestricted -force
(please keep in mind that this a global change, so be really careful with what you download and execute in the PowerShell. More on Execution Policies here).
Is there any equivalent to this for powershell?