次のようなことを $HOME/.ocamlinit
に書く
#use "topfind" ;;
let () =
Hashtbl.add
Toploop.directive_table "pwd"
(Toploop.Directive_none
(fun () -> print_endline (Sys.getcwd ())));
Hashtbl.add
Toploop.directive_table "ls"
(Toploop.Directive_none
(fun () ->
Sys.readdir (Sys.getcwd ())
|> Array.iter print_endline))