You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed that using nb add or nb edit with the --edit flag causes nb to stop responding to any further requests until the editor session is closed.
I was able to rectify this in my scripts by doing add/edit command with it's relevant --content section first, and then separately executing nb open to open the editor to the file, but I wonder if this is a bug or something that can be fixed? I understand the issue is probably related to the git usage pattern, maybe you can help me make sense of the workflow I should use instead.
Here was the pre-workaround version of my function:
functionmy_log() {
# Use nb to add a diary entry. If it's the first entry of the day, use a full date line, otherwise use an abbreviated# one.
long_form_date=$(date '+%A, %B %d, %Y')
short_form_date=$(date '+%H:%M')
calendar_date=$(date '+%Y-%m-%d')
shortmsg=$'\n'"$@"
edit=$(if [ $#-eq 0 ];thenecho"--edit";elseecho""; fi)
entries=$(nb list --type=log.md "${calendar_date}.log.md")if [ $?-eq 0 ];then# entries WERE found, so use nb edit
nb edit "${calendar_date}.log.md" --content "## ${short_form_date}${shortmsg}"$editelse# entries were NOT found, so use nb add
nb add "${calendar_date}.log.md" --title "${long_form_date}" --content "## ${short_form_date}${shortmsg}" --type=log.md $editfi
}
Here is the workaround function:
functionmy_log() {
# Use nb to add a diary entry. If it's the first entry of the day, use a full date line, otherwise use an abbreviated# one.
long_form_date=$(date '+%A, %B %d, %Y')
short_form_date=$(date '+%H:%M')
calendar_date=$(date '+%Y-%m-%d')
shortmsg=$'\n'"$*"# First, create all preamble for this entry including the file itself if needed
entries=$(nb list --type=log.md "${calendar_date}.log.md")if [ $?-eq 0 ];then# entries were found, so use nb edit
nb edit "${calendar_date}.log.md" --content "## ${short_form_date}${shortmsg}"else# entries were NOT found, so use nb add
nb add "${calendar_date}.log.md" --title "${long_form_date}" --content "## ${short_form_date}${shortmsg}" --type=log.md
fi# If no args were passed, open the file in the editorif [ $#-eq 0 ];then# Why do this and not just use --edit? Because --edit _locks nb systemwide_.
nb open "${calendar_date}.log.md"fi
}
I'm sure there's something I'm not quite getting here, but I'm currently unblocked with my workaround so please of course feel free to close this issue if there's nothing to track on your end.
The text was updated successfully, but these errors were encountered:
Thanks @voxelv. It looks like my reading of #300's solution on lines 144-146, this plugin is not using --edit but rather nb edit. My issue is specifically related to using either nb add or nb edit while using the --edit flag to indicate that the editor should be invoked. In particular, my problem is that the resulting editor session seems to hold a "lock" of some sort on either nb itself (globally across all processes) or else on the underlying git repo. (Note the obscure corner case where nb edit is used with --edit which corresponds to the case that we want to append content to a document AND THEN, afterwards, open the resulting document in an editor.)
Can you tell me if the plugin exhibits this behavior as well? From my reading it doesn't seem to invoke --edit in any case so I don't know if a test can be made.
(An extra word aside here for my use case: I am trying to design an 'interactive log' of sorts where a long-lived editor session is set to autoload changes from scripted prompts while allowing the user to attach prose and links in context buffers. It's all very hacked and alpha right now, but the code is working and can be seen here.)
I have noticed that using
nb add
ornb edit
with the--edit
flag causes nb to stop responding to any further requests until the editor session is closed.I was able to rectify this in my scripts by doing add/edit command with it's relevant --content section first, and then separately executing
nb open
to open the editor to the file, but I wonder if this is a bug or something that can be fixed? I understand the issue is probably related to the git usage pattern, maybe you can help me make sense of the workflow I should use instead.Here was the pre-workaround version of my function:
Here is the workaround function:
I'm sure there's something I'm not quite getting here, but I'm currently unblocked with my workaround so please of course feel free to close this issue if there's nothing to track on your end.
The text was updated successfully, but these errors were encountered: