Add script to create zttelkasten notes
This commit is contained in:
		
							
								
								
									
										45
									
								
								.local/bin/on
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										45
									
								
								.local/bin/on
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,45 @@ | |||||||
|  | #!/usr/bin/env python3 | ||||||
|  |  | ||||||
|  | import os | ||||||
|  | import textwrap | ||||||
|  | import argparse | ||||||
|  | import subprocess | ||||||
|  |  | ||||||
|  | from datetime import date | ||||||
|  |  | ||||||
|  | def load_args(): | ||||||
|  |     """loads cli parameters""" | ||||||
|  |     parser = argparse.ArgumentParser( | ||||||
|  |         description="Takes a snapshot of all pad contents" | ||||||
|  |     ) | ||||||
|  |     parser.add_argument('all', nargs=argparse.REMAINDER) | ||||||
|  |     args = parser.parse_args() | ||||||
|  |     return vars(args) | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def main(): | ||||||
|  |     args = load_args() | ||||||
|  |     name = ' '.join(args['all']) | ||||||
|  |     today = date.today().strftime('%Y-%m-%d') | ||||||
|  |     filename = f'/home/bredow/nextcloud/perso/notes/zettelkasten/inbox/{today}_{name}.md' | ||||||
|  |      | ||||||
|  |     content = textwrap.dedent(f"""\ | ||||||
|  |         --- | ||||||
|  |         date: {today} | ||||||
|  |         tags: | ||||||
|  |           -  | ||||||
|  |         --- | ||||||
|  |  | ||||||
|  |     """) | ||||||
|  |      | ||||||
|  |     if not os.path.exists(filename): | ||||||
|  |         with open(filename, 'w') as file: | ||||||
|  |             file.write(content) | ||||||
|  |  | ||||||
|  |     subprocess.run(['nvim', '+normal G$', '+startinsert', filename]) | ||||||
|  |     os._exit(0) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if __name__ == "__main__": | ||||||
|  |     main() | ||||||
		Reference in New Issue
	
	Block a user
	 Florestan Bredow
					Florestan Bredow