Skip to content

Instantly share code, notes, and snippets.

@x8x
Last active June 1, 2017 06:14
Show Gist options
  • Save x8x/affd2c0b556027b423bfa95c17770096 to your computer and use it in GitHub Desktop.
Save x8x/affd2c0b556027b423bfa95c17770096 to your computer and use it in GitHub Desktop.
Linux and macOS console history + init script:
Red []
;short version utils:
join: func[a b][append copy a b]
delete: func[f][call/wait rejoin ["rm '" f "'"]]
#include %console.red
system/options/home: join to-file get-env "HOME" %/
history: object [
f: join make-dir join system/options/home %.red/ %.red_history
length: 500
start: does [
if exists? f [
system/console/history: load f
]
exit
]
set 'quit does [
save f reverse copy/part union
reverse system/console/history
reverse any [
all[
exists? f
load f
]
[]
]
length
quit-return 0
]
set 'q :quit
clear: does [
delete f
system/words/clear system/console/history
exit
]
]
history/length: 1000
history/start
;put your init stuff in ~/.red/user.red
object [
either exists? f: join system/options/home %.red/user.red [
do f
][
write f {Red []^/^/;put your init stuff here^/}
]
]
system/console/launch
@x8x
Copy link
Author

x8x commented Apr 27, 2017

Instructions:

  1. download red master repository
  2. in file %environment/console/console.red replace system/console/launch with ;system/console/launch
  3. save above script in %environment/console/ as %build-console.red
  4. compile: red -r -o console build-console.red
  5. run it ./console
  6. eat a mango and enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment