 
 (message (format "QuickOpen loaded at %s" quickopen-dir-base))
 
-(global-set-key (kbd "M-O") (lambda ()
-  (interactive "")
-  (quickopen)))
-(global-set-key (kbd "A-O") (lambda ()
-  (interactive "")
-  (quickopen)))
-(global-set-key (kbd "s-O") (lambda ()
-  (interactive "")
-  (quickopen)))
+(defun quickopen-has-gui ()
+  (when (fboundp 'window-system)
+    (when window-system
+      1)))
+
+(defun quickopen-curses ()
+  (message "Not implemented")
+  )
+
+(if (quickopen-has-gui)
+    (progn
+      (global-set-key (kbd "M-O") (lambda ()
+                                    (interactive "")
+                                    (quickopen)))
+      (global-set-key (kbd "A-O") (lambda ()
+                                    (interactive "")
+                                    (quickopen)))
+      (global-set-key (kbd "s-O") (lambda ()
+                                    (interactive "")
+                                    (quickopen)))
+      )
+  (progn
+      (global-set-key (kbd "ESC O") (lambda ()
+                                    (interactive "")
+                                    (quickopen-curses)))
+    )
+  )
          (buffer-substring prev-point (- (point) prev-point))
        nil))))

(defun quickopen()
  (interactive "")
  (let* ((result (quickopen-run)))
    (when result
      (if (string-equal (substring result 0 3) "OK\n")
          (progn


(provide 'quickopen)

(defun quickopen-run-gui ()
  (with-temp-buffer
    (goto-char (point-max))
    (let* ((prev-point (point)))
