stitch

Note taking for messy minimalists

git clone git://mccd.space/stitch

export.ml (398B)

      1 let to_path path ~content =
      2   try
      3     let home = Sys.getenv_opt "HOME" in
      4     let path =
      5       match home with
      6       | Some home -> Str.replace_first (Str.regexp "~") home path
      7       | None -> path
      8     in
      9     let oc = open_out path in
     10     Printf.fprintf oc "%s\n" content;
     11     close_out oc;
     12     "Successfully wrote to " ^ path
     13   with
     14   | exn -> "Failed to write to path: " ^ Printexc.to_string exn