Skip to content

Instantly share code, notes, and snippets.

@IQAndreas
Last active December 21, 2015 08:09
Show Gist options
  • Save IQAndreas/6276512 to your computer and use it in GitHub Desktop.
Save IQAndreas/6276512 to your computer and use it in GitHub Desktop.
Want to run Shell/Bash commands but are sick and tired of how sickeningly untyped they are? Introducing JavaSH!
#!/bin/javash
# Both Bash and Java comments supported (not a feature, I was just too lazy to force one or the other)
// Some basic commands are included
echo("Hello world!");
// Others, you have to manually run
String currentDir = run("pwd");
echo(currentDir);
/* Note that you also have full access the Java libraries! */
// Alternatively, modules allow for adding "typed" commands like these
git.init();
file.touch("log");
file.chmod("777", "log");
Date date = new Date();
file.append("log", "Logged in " + date.toString());
git.add("log");
echo(git.status());
git.commit("Updated log file");
@IQAndreas
Copy link
Author

So long as you have javac installed, the library allows for the execution of code directly from the terminal (debating whether to use .javash extension to avoid confusion):

 $ ./helloWorld.java

Or

 $ javash helloWorld.java

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