         "less" swap 2array try-process
     ] [ drop ] if ;
 
-: gemini-ls ( -- )
-    LINKS [
-        1 + swap "[%d] %s\n" printf
-    ] each-index ;
+ : gemini-ls ( args -- )
+    PAGE swap "-l" = '[
+        1 + swap first2 swap
+        _ [ " (" ")" surround ] [ drop f ] if
+        "[%d] %s%s\n" printf
+    ] each-index
+    LINKS delete-all PAGE keys LINKS push-all ;
 
 : gemini-quit ( -- )
     "gemini.txt" temp-file ?delete-file 0 exit ;

! Copyright (C) 2021 John Benediktsson
! See http://factorcode.org/license.txt for BSD license

USING: accessors arrays combinators.short-circuit command-loop
formatting gemini gemini.private io io.directories
io.encodings.string io.encodings.utf8 io.files io.files.temp
io.launcher io.pipes kernel math math.parser namespaces present
sequences splitting system urls webbrowser ;

IN: gemini.cli


    ] when dupd remove! push ;

: gemini-history ( -- )
    HISTORY [ 1 + swap "[%d] %s\n" printf ] each-index
    LINKS delete-all HISTORY LINKS push-all ;

: gemini-print ( url body meta -- )
    f pre [
        PAGE delete-all
        gemini-charset decode string-lines [
            { [ pre get not ] [ "=>" ?head ] } 0&& [
                swap gemini-link present over 2array PAGE push
                PAGE length swap "[%s] %s\n" printf
            ] [
                gemini-line.
            ] if
        ] with each
        LINKS delete-all PAGE keys LINKS push-all
    ] with-variable ;

: gemini-get ( args -- )
