     (in-ns 'mapfs.core)
     (loop []
       (println)
-      (let [v (.readLine console "mapfs> ")]
+      (let [v (.readLine @CONSOLE "mapfs> ")]
         (when-not (= "exit" v)
           (try 
             (println (eval (read-string (str "(" v ")")))) 


(defn- init-terminal []
  (let [term (TerminalFactory/create)
        console (ConsoleReader. System/in System/out)]
    (.init term)
    (.addCompleter console completion-handler)
    [term console]))

(defn -main [& args]
  (println "Map FS - 0.1.0")  

            ;[clojure.java.shell :refer [sh]]
            )
  (:import [jline TerminalFactory TerminalFactory$Flavor]
           [jline.console ConsoleReader]
           [java.lang ProcessBuilder$Redirect])
  (:gen-class :main true))

(defonce ^:private FS_ROOT (atom nil))
(defonce ^:private CURRENT_DIR (atom []))
(defonce ^:private FS_FILENAME (atom nil))
(defonce ^:private CONSOLE (atom nil))
(defonce ^:private TERMINAL (atom nil))

(defn write-fs! 
  "Write current filesystem to filename as EDN."
