├── README └── m /README: -------------------------------------------------------------------------------- 1 | memoir is intended to be a minimal cli diary. 2 | 3 | Usage: 4 | Run memoir by typing 'm' into a terminal. 5 | Type out your memoir, and it will write the entry to '~/.memoir' and exit as soon as an empty line is encountered. 6 | If the first line is empty, it wont write the entry. 7 | You can also send a SIGINT to exit the program without side effects. 8 | 9 | Alternatively, you can run 'm' with any number of arguments. 10 | Once you run 'm' with the arguments, it will automatically add a one line entry to '~/.memoir'. 11 | 12 | Format of '~/.memoir': 13 | date 14 | entry 15 | Entries are seperated by a line of dashes. 16 | 17 | Dependencies: 18 | python3 19 | -------------------------------------------------------------------------------- /m: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import time 4 | import os 5 | import sys 6 | 7 | # add the current local time to the entry header 8 | lines = [ time.asctime() + '\n' ] 9 | 10 | if len( sys.argv ) > 1: 11 | lines.append( ' '.join( sys.argv[ 1: ] ) ) 12 | lines[-1] += '\n' 13 | else: 14 | while 1: 15 | try: 16 | line = input() 17 | except EOFError: 18 | break 19 | 20 | # get more user input until an empty line 21 | if len( line ) == 0: 22 | break 23 | else: 24 | lines.append( line + '\n' ) 25 | 26 | 27 | # only write the entry if the user entered something 28 | if len( lines ) > 1: 29 | memoir_path = os.path.expanduser( '~/.memoir' ) 30 | 31 | # prepend a seperator only if the file exists ( there are entries already in there ) 32 | if os.path.exists( memoir_path ): 33 | lines.insert( 0, '--------------------\n' ) 34 | 35 | with open( memoir_path, 'a' ) as f: 36 | f.writelines( lines ) 37 | --------------------------------------------------------------------------------