A Lisp REPL as my main shell
ambrevar.xyz
A Lisp REPL as my main shell
1–10 of 31 posts
Re: A Lisp REPL as my main shell
#2PS: I look forward to trying this out! Since I don’t know much Common Lisp, are there particularly useful libraries that would make it easy to cover functionality commonly used through the shell? I’d love to see a tutorial with a compilation of examples. EDIT: Found some useful stuff in the CL cookbook (Eg. section on files & directories) https://lispcookbook.github.io/cl-cookbook/
Re: A Lisp REPL as my main shell
#3Re: A Lisp REPL as my main shell
#4A very well done article! I wonder what an integration with a Python REPL might look like.
Re: A Lisp REPL as my main shell
#5There are a couple of techniques:
1) Check for use of certain escape sequences in the output.
2) Check PTY terminal modes using tcgetattr, especially for raw mode
I think combining (1) and (2) you could come up with some heuristics that would work 99% of the time, without hardcoding names of fullscreen apps or anything else like that.
(Really this isn't "ncurses detection" per se, you can have a full-screen terminal app without using any curses library.)
Re: A Lisp REPL as my main shell
#6For processes, I wrote something that is not finished, not polished, but if anyone want to steal from it, go ahead:
https://github.com/christophejunke/pipeline
This allows to spawn processes or threads to pipeline input/output, like done usually with | in shells
(with-pipeline ()
(program "ls" (namestring (merge-pathnames "bin/" (user-homedir-pathname))))
(program "sed" "s/a/aaaa/")
(tee/error) ;; "tee" and output a copy to error
(program "wc" "-c")
#'read)
https://github.com/christophejunke/pipeline/blob/master/test...The nmcli.lisp example starts an nmcli process and filters its output to build Lisp objects representing connections:
https://github.com/christophejunke/pipeline/blob/master/nmcl...
Re: A Lisp REPL as my main shell
#7Re: A Lisp REPL as my main shell
#8Outer most parens should be optional, if you're running ls you don't want to type (ls).
Grouping flags, files and options is difficult: ls -lh file could become (ls (h l) file) (ls (flags h l) (files file)) (ls -l -h file) (ls -lh file) none of the options are particularly good or lispy.
You need a full editor on the command line. Shells are designed for teletypes, lisps are designed for glass terminals.
All in all not I'm sure that an s-expression based system is the right fit for a low level interface to the computer. That said I did enjoy my experiments a lot more than I did using shells. Were I to try it again I would have it is a higher level language that compiles down to a shell.
Re: A Lisp REPL as my main shell
#9It's not Lisp but Scala so may not be the authors language of choice however it can be used as a Shell: https://ammonite.io/#Ammonite-Shell
I am personally using it and compared to a classical shell like Bash it's really nice for more structured data related tasks (exploring some API, checking some data, creating a bunch of PRs at once, ...).
It also makes use of Scala's adjustable syntax and functional concepts so you basically get shell piping but in a strongly typed fashion (e.g. `ls.! |? (_.ext == "txt") | (os.read)` would produce a list of strings representing the contents of all files ending in .txt of the current directory).
Also I am curious what people think of PowerShell which as of PowerShell Core is usable on all platforms as well.
Re: A Lisp REPL as my main shell
#10A bit late on the uptake, but welcome to the party of realizing that the shell is not be all end all of computing.