Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document example use cases #1

Open
sloansparger opened this issue Jun 12, 2020 · 2 comments
Open

Document example use cases #1

sloansparger opened this issue Jun 12, 2020 · 2 comments

Comments

@sloansparger
Copy link
Owner

It would be useful to have some visual documentation on how to utilize this CLI for people wanting to start and build custom workflows using the CLI. Please leave a comment of something you'd like to see documented below, or upvote existing ideas!

@bcdavasconcelos
Copy link

Perhaps how to interact with the CLI via Applescript? I have been trying to do so, but apparently that is not very simple since do shell script uses sh instead of zsh. Any help would be appreciated.

(My end goal is to set up some sort of sync with an external folder. The python script available did not work out very well for me)

@sloansparger
Copy link
Owner Author

@bcdavasconcelos apologies for the slow reply. I'm not familiar with applescript at all, so I'm not able to help there.

If you were to use the CLI in bash/zsh I would do something like this:
bear search " " | awk 'BEGIN {FS="\t"}; {print "bear open-note " $1 " | head"}' | xargs -0 bash -c

  1. bear search " " gets all notes with a space (best way I know to find all of them).
  2. Pipe result into awk. Bear search results an {id}\t{title} for each note. We just want the id for each note. Awk will let us do that for each line by setting FS=\t (I suggest reading learn awk in 20 minutes if you're unfamiliar awk). We then build a string "bear open-note " $1 " | head" Which lets us grab the first 10 lines of every single note in bear. You can replace head with any command, in your case you may want to echo the contents into a file.
  3. Pipe the resulting string from awk back into bash using xargs. This allows us to run a command for each line of our awk output, which is a single bash script.

Maybe fetching all notes and doing something with their contents might be a common enough use case I should create an example for...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants