Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash function to jump to any Johnny.Decimal folder
# 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.
@NeodymiumPhish

This comment has been minimized.

Copy link

@NeodymiumPhish NeodymiumPhish commented Feb 6, 2019

Is there any equivalent to this for powershell?

@ayrtonoropeza

This comment has been minimized.

Copy link

@ayrtonoropeza ayrtonoropeza commented Jul 30, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment