trybash / bash-emulator Goto Github PK
View Code? Open in Web Editor NEWEmulate a bash environment in plain JS. In your browser.
Home Page: https://trybash.github.io/bash-emulator
License: MIT License
Emulate a bash environment in plain JS. In your browser.
Home Page: https://trybash.github.io/bash-emulator
License: MIT License
$ cp -R / /backup
$ ls
README.txt backup backupREADME.txt backuphome home
hi
Using cp -R / /backup
does not work like it should ๐ญ
@jorinvo maybe you know how to fix it?
Implement uniq
command.
We tried writing the code as simple, modular and straight-forward as possible, but it would be still better to have some explanation about what certain modules and functions do.
I think it wouldn't even be necessary to just an official documentation style and document every parameter.
I'm more thinking about having some introduction at the to of each file. It should be simpler for new contributors to see what the different parts of the project do.
Should be easy to add the -p
flag to mkdir
.
always inline state like this bashEmulator({ })
Implement head
command.
Implement tail
command.
https://github.com/xtermjs/xterm.js is a popular terminal emulator
with LocalEchoController we can add custom interpreters
see also https://github.com/RangerMauve/xterm-js-shell/blob/master/index.js
benefit of bash-emulator: its faster for plain text (no ansi escapes)
Right now the only file types we have are file
and dir
.
simlink
could be an additional one.
We would need to think about the implementation but it shouldn't be too difficult.
With this we should also implement the ln -s
command.
Think about changing file structure first (see #2)
It would be nice to be able to expand file paths using the *
operator.
This should be implemented in a reusable way so all system methods could use it.
For now the simple *
would be good enough.
Later on we can still at **
.
We already have some chapters prepared for our game to teach about pipes |
and redirection<
/ >
.
This can be implemented in a generic way in the .run()
system method.
The command interface is already designed in a way to allow streaming of input and output.
|
<
>
>>
We could implement &&
and ||
operators the same way we would implement pipes and redirection.
Commands are already designed to give us the exit codes which we can use for the logic operations.
Another thing we could implement is the ;
to separate lines.
However, I don't think we should try implementing more complex scripting features (like loops and functions).
always inline state like this bashEmulator({ })
Implement sort
command.
If I understand correctly, there's an internal completion.index
that keeps track of the last given completion. This variable should be reset when run
ning a command, or otherwise the completion behaviour will be quite weird.
Clear should be implemented by the demo itself since clearing the screen is specific to each terminal.
The API of the emulator is built with Promises to allow an asynchronous implementation.
The current implementation is all synchronous, in the browser.
All the commands are designed in a way to only interact with the state through the "system calls".
This way it should be possible to implement the "system calls" asynchronous without changing the commands.
An asynchronous implementation could run the system calls on a server for example, persist them or even allow multiple users to interact with the same system this way.
Even better would be to think first about further decoupling the system from the index.js
file. Would be nice to be able to choose with which system to initialize the emulator instance.
echo
command.
Only use after implementing #15.
"fs in the browser" is provided by multiple libraries
persistence usually via IndexedDB
they all implement the standard node fs api, but only the async functions
fs.readDir
fs.readFile
etc
feature request:
bash-emulator should support the async fs api by default
other tools compatible with the async fs api
Right now the file system is a flat structure.
This makes some operations easier. And it makes other more difficult.
The biggest issue is that the user can create a structure with holes. If the file system is not connected anymore, it's not really possible to navigate, it's broken.
Also a tree might be easier for the user to create.
Have to see how difficult it would be...
It would be nice if commands and directories could be completed using the tab key.
We should start with the easiest solution we can find and enhance it later on.
Is there a possibility to add create a new command in which the user should enter some information?
My real poc is to create a mini wizard like:
I reviewed the commands folder but I cannot find a command which response is a question to the user:
https://github.com/trybash/bash-emulator/tree/gh-pages/src/commands
Thanks for your time.
move it to a subfolder system/
. The tests too.
Implement wc
command.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.