Last active
June 1, 2017 06:14
-
-
Save x8x/affd2c0b556027b423bfa95c17770096 to your computer and use it in GitHub Desktop.
Linux and macOS console history + init script:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions:
%environment/console/console.red
replacesystem/console/launch
with;system/console/launch
%environment/console/
as%build-console.red
red -r -o console build-console.red
./console