Collection of zsh functions to work with Johnny.Decimal document hierachies More info can be found at https://johnnydecimal.com/
- Set the environment variable
JOHNNYDECIMAL_BASE
to the base directory- If this is not set, it will default to
~/johnny
- If this is not set, it will default to
source johnnydecimal.zsh
Add the following to programs.zsh.plugins
:
{
name = "zsh-johnnydecimal";
file = "johnnydecimal.zsh";
src = pkgs.fetchFromGitHub {
owner = "Amarandus";
repo = "zsh-johnnydecimal";
rev = "2d66d4e3cfd4054b9c32c580ba256e823f0491e9";
sha256 = "1l9mjykahvfgs919534hp9h85msss6jniwr2160qfn0jgskx5x2w";
};
}
Merge the following with an already existing home.sessionVariables
(or create a new one):
home.sessionVariables = {
# Path to johnny.decimal basedir
"JOHNNYDECIMAL_BASE" = "~/johnny/";
}
Don't forget to change the path.
jcd CATEGORY.UNIQUE
Changes the active directory to CATEGORY.UNIQUE
with pushd
.
Going back to the original directory can be done with popd
.
jcd CATEGORY.UNIQUE SRC [SRC [SRC ...]]
Copies SRC
to CATEGORY.UNIQUE
.
jcd CATEGORY.UNIQUE SRC [SRC [SRC ...]]
Moves SRC
to CATEGORY.UNIQUE
.
jmkarea CATEGORY DESC
Creates the area for CATEGORY
, using the given description.
CATEGORY
can be any index within the desired area.
jmkcat CATEGORY DESC
Creates the category CATEGORY
with the given description.
jmkuni CATEGORY.UNIQUE DESC
Creates the unique folder CATEGORY.UNIQUE
with the given description.
jwd CATEGORY.UNIQUE CMD [ARG [ARG [ARG ...]]]
Executes CMD [ARG [ARG [ARG ...]]]
inside the directory for CATEGORY.UNIQUE
.
$ export JOHNNYDECIMAL_BASE=/tmp/jd
$ find $JOHNNYDECIMAL_BASE
# Nothing here
$ jmkarea 10 Finance
mkdir: created directory '/tmp/jd/10-19 Finance'
$ jmkarea 20 Administration
mkdir: created directory '/tmp/jd/20-29 Administration'
$ jmkcat 21 "Company Registration"
mkdir: created directory '/tmp/jd/20-29 Administration/21 Company Registration'
$ jmkcat 22 Contracts
mkdir: created directory '/tmp/jd/20-29 Administration/22 Contracts'
$ jmkuni 22.01 "Cleaning contract"
mkdir: created directory '/tmp/jd/20-29 Administration/22 Contracts/22.01 Cleaning contract'
$ jmkuni 22.02 "Office Lease"
mkdir: created directory '/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease'
The resulting file structure is
$ find $JOHNNYDECIMAL_BASE
/tmp/jd
/tmp/jd/20-29 Administration
/tmp/jd/20-29 Administration/22 Contracts
/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease
/tmp/jd/20-29 Administration/22 Contracts/22.01 Cleaning contract
/tmp/jd/20-29 Administration/21 Company Registration
/tmp/jd/10-19 Finance
$ pwd
~/example
$ ls
'Security bond details.xlsx' 'Signed lease agreement.pdf' 'Terms & conditions.doc'
$ jcp 22.02 Security\ bond\ details.xlsx Signed\ lease\ agreement.pdf
'Security bond details.xlsx' -> '/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease/Security bond details.xlsx'
'Signed lease agreement.pdf' -> '/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease/Signed lease agreement.pdf'
$ jmv 22.02 Terms\ \&\ conditions.doc Signed\ lease\ agreement.pdf
copied 'Terms & conditions.doc' -> '/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease/Terms & conditions.doc'
removed 'Terms & conditions.doc'
# Note that it only copied the first file - not the second one, as that already exists
$ ls
'Security bond details.xlsx' 'Signed lease agreement.pdf'
$ find $JOHNNYDECIMAL_BASE
/tmp/jd
/tmp/jd/20-29 Administration
/tmp/jd/20-29 Administration/22 Contracts
/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease
/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease/Terms & conditions.doc
/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease/Signed lease agreement.pdf
/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease/Security bond details.xlsx
/tmp/jd/20-29 Administration/22 Contracts/22.01 Cleaning contract
/tmp/jd/20-29 Administration/21 Company Registration
/tmp/jd/10-19 Finance
$ pwd
~/example
$ jcd 22.02
/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease ~/example
$ ls
'Security bond details.xlsx' 'Signed lease agreement.pdf' 'Terms & conditions.doc'
$ pwd
/tmp/jd/20-29 Administration/22 Contracts/22.02 Office Lease
$ popd
~/example
$ pwd
~/example