15 Commits
1 ... master

Author SHA1 Message Date
6f0b418939 Updating documentation link. 2016-01-13 11:49:20 -08:00
thintz
27563113d9 Setup with chicken-install instead of makefile. 2012-12-05 09:01:45 -08:00
thintz
ebaf6763e3 Merge 2012-08-13 15:28:41 -07:00
thintz
d79a49d13f Add history file and executable to gitignore 2012-08-13 15:23:29 -07:00
thintz
fcd452aa10 Rename config file to .hiss 2012-08-13 15:20:47 -07:00
Thomas Hintz
4e9a29eac2 Add executable to gitignore 2012-08-13 14:57:52 -07:00
thintz
eb3dc0d2a4 from macros to functions 2012-08-07 14:06:31 -07:00
Thomas Hintz
591e4e9344 removed auto run, now uses explicit command running 2012-08-06 15:28:05 -07:00
Thomas Hintz
90ce2997d6 changed the output name to 'hiss' 2012-05-24 13:24:31 -07:00
Thomas Hintz
c3e712f381 reworked inner loop; now checks for a lisp symbol before trying to run on the system shell. also added helper function for converting a shell programs output to a list. 2012-05-24 13:24:20 -07:00
Thomas Hintz
9c4bb87ae8 add readme with a link to the documentation 2012-05-23 10:01:29 -07:00
8b05590440 Merge pull request #1 from iffsid/master
Minor packaging and version compatibility fix
2012-05-22 08:33:06 -07:00
Siddharth Narayanaswamy
1b8a8647e1 makefile, gitignore and backwards compatibility with <=4.6.4 for getenv 2012-05-21 19:35:30 -04:00
a262cc5f41 Added example rc file 2011-06-22 17:59:03 -04:00
4f5da89ea7 Removed unneeded regex dependency. 2011-05-27 22:09:03 -04:00
9 changed files with 93 additions and 36 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*~
hiss
.csi.history

15
.hiss Normal file
View File

@@ -0,0 +1,15 @@
(require-extension ansi-escape-sequences srfi-19)
(repl-prompt
(lambda ()
(let ((is-root? (lambda (user) (string=? user "root")))
(user (car (user-information (current-user-id)))))
(string-append "("
(set-text (if (is-root? user) '(fg-red) '(fg-green))
(string-append user "@" (or (get-host-name) "")))
")-("
(current-directory)
")-("
(date->string (current-date) "~T")
")"
"\n$ "))))

6
hiss.meta Normal file
View File

@@ -0,0 +1,6 @@
;;; hiss.meta -*- scheme -*-
((egg "hiss.egg")
(synopsis "hiss is a chicken scheme shell.")
(license "BSD")
(depends readline))

60
hiss.scm Normal file
View File

@@ -0,0 +1,60 @@
;;; documentation at http://thintz.com/chicken-scheme-shell
(use readline srfi-1)
(include "macros.scm")
(define (getenv2 e)
;; handles exorcism of getenv from 4.6.4 onwards
(handle-exceptions
exn
(get-environment-variable e)
(getenv e)))
(current-input-port (make-gnu-readline-port))
(gnu-history-install-file-manager
(string-append (or (getenv2 "HOME") ".") "/.csi.history"))
(repl-prompt (lambda () "$ "))
(define config-file
(make-parameter (string-append (or (getenv2 "HOME") ".") "/.hiss")))
(when (file-exists? (config-file))
(load (config-file)))
(define exit? (make-parameter #f))
(define (exit) (exit? #t))
(define (%run-cmd cmd) (with-input-from-pipe cmd read-file))
; now we can can actually use things in a more lispy way
; #;1> (cmd->list "ls" read-line)
; (file1 file2 file3)
; #;2> (map (lambda (file) (run (string-append "cat " file)))
; (cmd->list "ls" read-line))
; ...contents of all the files in the current directory
(define (cmd->list cmd read-func)
(with-input-from-pipe
cmd
(lambda ()
(letrec ((get-next (lambda (o)
(let ((v (read-func)))
(if (not (eof-object? v))
(get-next (cons v o))
(reverse o))))))
(get-next '())))))
(define (run cmd) (process-wait (process-run cmd)))
(define (_ . r) (cmd->list (fold (lambda (e o) (++ o " " e)) "" r) read-line))
(define (shell-repl)
(if (exit?)
#t
(begin (handle-exceptions
exn
(begin (print-error-message exn)
(display (with-output-to-string (lambda () (print-call-chain)))))
(let ((x (read)))
(write (eval x))))
(newline)
(shell-repl))))
(shell-repl)

7
hiss.setup Normal file
View File

@@ -0,0 +1,7 @@
;;; hiss.setup -*- scheme -*-
(compile -S -O3 -d1 hiss.scm -o hiss)
(install-program 'hiss
'("hiss")
`((version "2")))

View File

@@ -1,6 +0,0 @@
(load "shell.scm")
(define scheme-dir (make-parameter "/home/teejay/thomas/programming/scheme"))
(define ++ string-append)
(load (++ (scheme-dir) "/network/network.scm"))

1
macros.scm Normal file
View File

@@ -0,0 +1 @@
(define-syntax _raw (syntax-rules () ((_raw . cmd) (run (fold (lambda (e o) (string-append o " " (->string e))) "" 'cmd)))))

1
readme.md Normal file
View File

@@ -0,0 +1 @@
[documentation](http://thintz.com/projects/hiss)

View File

@@ -1,30 +0,0 @@
(use shell readline regex)
(current-input-port (make-gnu-readline-port))
(gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history"))
(repl-prompt (lambda () "$ "))
(define config-file (make-parameter (string-append (or (getenv "HOME") ".") "/.hintz-shellrc")))
(when (file-exists? (config-file))
(load (config-file)))
(define exit? (make-parameter #f))
(define (exit) (exit? #t))
(define (shell-repl)
(if (exit?)
#t
(let ((x (read)))
(begin (handle-exceptions
exn
(handle-exceptions
exn
(begin (print-error-message exn)
(display (with-output-to-string (lambda () (print-call-chain)))))
(execute (list x)))
(display (eval x))
(newline))
(newline)
(shell-repl)))))
(shell-repl)