mirror of https://github.com/nirenjan/dotfiles.git
				
				
				
			Fix check_empty and add show command to note
check_empty for restore was trying to run a git checkout in the current working directory, instead of in the ~/.notes directory. Fix this issue note_show uses less to display the contents of the note file.master
							parent
							
								
									8d0349f999
								
							
						
					
					
						commit
						2fda4cbad2
					
				
							
								
								
									
										20
									
								
								note
								
								
								
								
							
							
						
						
									
										20
									
								
								note
								
								
								
								
							|  | @ -68,11 +68,14 @@ check_empty() { | ||||||
|     then |     then | ||||||
|         if [[ "$1" == "restore" ]] |         if [[ "$1" == "restore" ]] | ||||||
|         then |         then | ||||||
|  |             cd "$NOTES_DIR" | ||||||
|             gitfile=$(basename "$note_file") |             gitfile=$(basename "$note_file") | ||||||
|             git checkout $gitfile |             git checkout $gitfile | ||||||
|  |             echo "Restored empty note $note_arg" | ||||||
|         elif [[ "$1" == "delete" ]] |         elif [[ "$1" == "delete" ]] | ||||||
|         then |         then | ||||||
|             rm -f $note_file |             rm -f $note_file | ||||||
|  |             echo "Deleted empty note $note_arg" | ||||||
|         fi |         fi | ||||||
| 
 | 
 | ||||||
|         exit |         exit | ||||||
|  | @ -198,6 +201,19 @@ note_edit() { | ||||||
|     echo "Updated note '$note_new_title'" |     echo "Updated note '$note_new_title'" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | note_show() { | ||||||
|  |     check_dir | ||||||
|  |     check_arg | ||||||
|  |     title_to_name | ||||||
|  |     if ! note_exists | ||||||
|  |     then | ||||||
|  |         echo "Cannot find note '$note_arg'!" | ||||||
|  |         exit | ||||||
|  |     fi | ||||||
|  | 
 | ||||||
|  |     less -R $note_file | ||||||
|  | } | ||||||
|  | 
 | ||||||
| note_delete() { | note_delete() { | ||||||
|     check_dir |     check_dir | ||||||
|     check_arg |     check_arg | ||||||
|  | @ -266,6 +282,10 @@ parse_args() { | ||||||
|         note_edit |         note_edit | ||||||
|         ;; |         ;; | ||||||
| 
 | 
 | ||||||
|  |     "show") | ||||||
|  |         note_show | ||||||
|  |         ;; | ||||||
|  | 
 | ||||||
|     "del" | "delete") |     "del" | "delete") | ||||||
|         note_delete |         note_delete | ||||||
|         ;; |         ;; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue