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 input to your flake.nix
:
inputs = {
zsh-johnnydecimal.url = "github:CRTified/zsh-johnnydecimal";
};
Afterwards, you can either add zsh-johnnydecimal.nixosModules.globalModule
to your
global NixOS configuration, which makes zsh-johnnydecimal
available for all
users configured with home-manager
, or you add zsh-johnnydecimal.nixosModules.hmModule
to the modules loaded by home-manager
.
In either case, users will have two options available:
programs.zsh.johnnydecimal.enable
enables the J.D integration (default:false
)programs.zsh.johnnydecimal.basePath
configures the base path for your J.D file structure (default:~/johnny/
)
jcd CATEGORY.UNIQUE
Changes the active directory to CATEGORY.UNIQUE
with pushd
.
Going back to the original directory can be done with popd
.
jcp CATEGORY.UNIQUE SRC [SRC [SRC ...]]
Copies SRC
to CATEGORY.UNIQUE
.
jmv 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