Skip to content

Instantly share code, notes, and snippets.

@draegtun
Last active June 8, 2018 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draegtun/83ae0cd3307eb20ee010d8949121c4ba to your computer and use it in GitHub Desktop.
Save draegtun/83ae0cd3307eb20ee010d8949121c4ba to your computer and use it in GitHub Desktop.
An example REPL config file (~/.rebol/repl-skin.reb)
Rebol [
title: "example REPL skin config"
date: 30-Mar-2017
version: 0.0.1
]
;; shortcuts I like!
q: :quit
?: :help
;; REPL makes me feel welcome!
repl: system/repl
repl/print-greeting: does [
print-newline
print ["Hello" uppercase/part get-env "USER" 1]
print ["I hope you'll enjoy your stay with us today -" now]
print ["You are in" what-dir]
]
;; can change prompt/result prefix
repl/result: "rebol says: " ;; changed from "=="
;; or can overwrite prompt completely, here adding [counter]
repl/print-prompt: does [print/only rejoin ["[" repl/counter "]" space]]
;; print this after each line of input given (except multi-line entries)
repl/print-gap: does [print "--------------------------------------------------"]
;; hook into input line and apply transformations.
repl/input-hook: function [s] [
parse s [
";q" end (s: "quit")
| {\h} (change/part s {help } 2)
]
s
]
; Above ";q" aliases to "quit" and "\h" to "help"
; so "\h print" same as "help print". NB. space is superfluous, can do "\hprint"
;; add shortcut
repl/add-shortcut 'd [now]
;; dialect
repl/dialect-hook: function [s] [
s: copy s
parse s [
m: 'baz set w: word! end (change m 'print change next m to-string w)
]
s
]
**************************************************************************
** **
** REBOL 3.0 (Ren-C branch) **
** **
** Copyright: 2012 REBOL Technologies **
** Copyright: 2012-2017 Rebol Open Source Contributors **
** Apache 2.0 License, see LICENSE. **
** Website: http://github.com/metaeducation/ren-c **
** **
** Version: 2.102.0.2.5 **
** Platform: Macintosh osx-x86 **
** Build: 21-Apr-2017/13:51:44 **
** Commit: _ **
** **
** Language: English **
** Locale: United Kingdom **
** Home: ./ **
** **
**************************************************************************
Important notes:
* Sandbox and security are not available.
* Direct access to TCP HTTP required (no proxies).
Special functions:
Help - show built-in help information
REPL skinning:
Loaded skin - /Users/barry/.rebol/repl-skin.reb
Hello Barry
I hope you'll enjoy your stay with us today - 21-Apr-2017/15:06:45+1:00
You are in /Users/barry/code/GitHub/ren-c/make/
--------------------------------------------------
[1] 1 + 1
rebol says: 2
--------------------------------------------------
[2] \h now
USAGE:
NOW /year /month /day /time /zone /date /weekday /yearday /precise /utc
DESCRIPTION:
Returns current date and time with timezone adjustment.
NOW is a function .
REFINEMENTS:
/year
Returns year only
/month
Returns month only
/day
Returns day of the month only
/time
Returns time only
/zone
Returns time zone offset from UCT (GMT) only
/date
Returns date only
/weekday
Returns day of the week as integer (Monday is day 1)
/yearday
Returns day of the year (Julian)
/precise
High precision time
/utc
Universal time (no zone)
--------------------------------------------------
[3] d
rebol says: 21-Apr-2017/15:08:22+1:00
--------------------------------------------------
[4] baz blah
blah
--------------------------------------------------
[5] ;q
==== some notes ====
[2] is input-hook (\h)
[3] is a shortcut (d)
[4] is dialect-hook
[5] is input-hook (changing ";q" to "quit"... so can intercept comments)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment