zk-org / zk

A plain text note-taking assistant
https://zk-org.github.io/zk/
GNU General Public License v3.0
1.71k stars 131 forks source link

Feature request: create directory #306

Closed kiil closed 1 year ago

kiil commented 1 year ago

I am using zk with hugo cms.

Hugo has a concept of page bundles, where a bundle lives in its own (sub)directory.

But currently, as I understand it, zk cannot create a directory.

For example:

zk new --title "testtitle" existing_dir/new_dir

will make zk respond zk: error: new note: existing_dir/new_dir: directory not found

My feature request is to have an option configurable in the config file and as a command line option to enable zk to create directories.

mickael-menu commented 1 year ago

Would an alias work for you?

[alias]
newdir = "mkdir -p $1;zk new $@"

The only limitation is that you need to pass the dir as the first argument, and the flags after.

zk newdir existing_dir/new_dir --title "testtitle"
kiil commented 1 year ago

Nice solution!

kiil commented 1 year ago

This does not seem to work with more than one word in the title.

With:

SHELL=/usr/bin/sh
ZK_SHELL=/usr/bin/sh

The following

sh-5.1$ zk newdir tst/test --title='word1 word2'

Gives

zk: error: unexpected argument word2
kiil commented 1 year ago

This seems to be a general problem with aliases.

Given

[alias]
n = "zk new $@"

The command

sh-5.1$ zk n testdir --title='one two'

gives

zk: error: unexpected argument two
kiil commented 1 year ago

Can be solved like so:

newdir = 'mkdir -p $1;zk new "$@"'