Cross-platform Linux commands in ES6

Related tags

Command Line cash
Overview

Cash

Cross-platform Linux commands in pure ES6

Build Status Windows Build Status Coverage Status Gitter XO code style

Cash is a cross-platform implementation of Unix shell commands written in straight ES6. No native compiling and no external dependencies.

While young, Cash aims to offer an alternative Linux feel on Windows and to open the door to cross-platform bash scripting in a Javascript environment.

> npm install cash -g
> cash
$

Cash

Woah.

Yeah. But it gets better.

Let's mix some Windows & Unix commands together:

$ ipconfig | grep IPv4 | sort
IPv4 Address. . . . . . . . . . . : 10.10.40.50
IPv4 Address. . . . . . . . . . . : 192.168.100.11
$

Learn more

But I don't want to type "cash"

No problem. Let's make all commands global on your system:

> npm install cash-global -g
> ls -lah

Learn more

Nice, but I only want certain commands

You're covered!

> npm install cash-ls -g
> npm install cash-grep -g

Learn more

Wow. But I want this programmatically!

Again, you're in business:

const $ = require('cash');
const out = $.ls('.', {l: true});

Not terse enough? How about this:

const out = $('ls -lah');

Not 😎 enough? Try this:

require('cash') `
  cp -R ./src ./dest
  ls | grep *-spec.js | cat
  rm ./specResults.html 
`;

For even better programmatic Unix commands, check out ShellJS.

Learn more

Isn't this impossible to do in Node?

It was, before Vorpal.

Made with by dthree.

Love it? Give it a or a tweet to help spread the word!

Notice

This is now an OPEN Open Source project. I am not able to invest a significant amount of time into maintaining Cash and so am looking for volunteers who would like to be active maintainers of the project. If you are interested, shoot me a note.

Contents

Introduction

Cash is a project working on a cross-platform implementation of the most used Unix-based commands in pure JavaScript and with no external dependencies.

The goal of Cash is to open up these commands to the massive JavaScript community for the first time, and to provide a cleaner, simpler and flexible alternative to applications like Cygwin for those wanting the Linux feel on Windows.

Cash was built with strict attention to nearly exact implementations and excellent test coverage of over 200 unit tests.

Supported commands

The following commands are currently implemented:

  • alias
  • cat
  • clear
  • cd
  • cp
  • echo
  • export
  • false
  • grep
  • head
  • kill
  • less
  • ls
  • mkdir
  • mv
  • pwd
  • rm
  • sort
  • source
  • tail
  • touch
  • true
  • unalias

Want more commands?

Configuration

Want to configure things to your heart's content? Just add your configurations in a .cashrc file (_cashrc also works, for Windows folk) and put that in your home directory. This supports anything you can do inside a cash command prompt (exporting environmental variables, aliases, etc.).

Contributing

We are currently looking for Core Team members who can push forward Cash at a rapid rate. Are you an awesome developer up to the challenge? Send me a ping.

Awesome contributors

  • @nfischer: Added source, export, true and false commands, among several other contributions.
  • @safinn: Added clear and tail commands.
  • @legien: Added head command.
  • @cspotcode: Implemented template literal execution.

FAQ

Why Cash?

In its very essence, Cash replaces the Windows CLI prompt (>) with the Unix one ($), the dollar symbol.

Cash was most fitting in this sense:

Ask and ye shall receive

> cash
$

Cash is also a play on the word bash, and is actually[1] a recursive acronym for Cash Shell.

Shout out to @aseemk for donating the name.

Doesn't ShellJS do this?

No.

For those who don't know, ShellJS is an awesome Node package that implements UNIX shell commands programatically in JavaScript. Check it out - really. While ShellJS was tremendously helpful in figuring out how to accomplish Cash, the two do not really conflict.

ShellJS gives the feel of UNIX commands in a code environment, but aims to implement the commands in a way that makes sense for a JavaScript library. This means that many commands return JavaScript objects, and some of the rougher and more dangerous edges of bash have been softened a bit.

For example, with cash:

$('ls'); // 'node_modules\n'

$('echo foo > foo.txt');

With ShellJS:

ls(); // ['node_modules'];

echo('foo').to('foo.txt');

Team

David Caccavella Nate Fischer
David Caccavella Nate Fischer

Want to join the team? Let us know.

License

MIT © David Caccavella

Comments
  • [Windows 10] npm install cash-global -g does not work

    [Windows 10] npm install cash-global -g does not work

    1. npm install cash-global -g
    2. Restart pc
    3. 'ls' is not recognized as an internal or external command, operable program or batch file

    However when I do cash it works as before. Am I missing something?

    C:\Users\stani>node -v
    v5.9.1
    C:\Users\stani>npm -v
    3.8.3
    
    opened by stanislavromanov 23
  • New command: source

    New command: source

    This adds source as requested in the roadmap.

    This executes any given cash script in the current environment, allowing it to modify variables, aliases, current directory, etc.

    I also added in code to check for an initialization file, as requested in #20. This file is named .cashrc on Linux/unix systems (following the common convention), and is named _cashrc for Windows (this is consistent with how vim looks for _vimrc, _gvimrc, etc. This file must be located in the user's home folder.

    I tried allowing this to be an external command, so deps and such should be double checked for that.

    opened by nfischer 12
  • ls with both directory and file arguments still isn't quite right

    ls with both directory and file arguments still isn't quite right

    Just tried this after #60 got merged. The output still doesn't seem quite right. Here's the output I'm seeing from cash:

    bash $ ./bin/cash.js
    nate@lenovoyoga:~/programming/cash$ ls README.md bin/
    README.mdalias.js    cash.js     cat.js      cd.js       clear.js
    cp.js       echo.js     export.js   false.js    grep.js
    head.js     kill.js     less.js     ls.js       mkdir.js
    mv.js       parser.js   pwd.js      rm.js       sort.js
    source.js   tail.js     touch.js    true.js     unalias.js
    nate@lenovoyoga:~/programming/cash$ exit
    bash $ ls README.md bin/
    README.md
    
    bin/:
    alias.js  cp.js      head.js   mv.js      source.js
    cash.js   echo.js    kill.js   parser.js  tail.js
    cat.js    export.js  less.js   pwd.js     touch.js
    cd.js     false.js   ls.js     rm.js      true.js
    clear.js  grep.js    mkdir.js  sort.js    unalias.js
    

    If multiple arguments are passed, directories should be displayed with the directory name above, followed by a colon (ex. bin/:). I couldn't find this issue if only directory arguments are used, only when both file and directory arguments are used.

    opened by nfischer 11
  • Support for globbing?

    Support for globbing?

    Just tried this out with npm install -g cash on my Ubuntu box with node 5.3. It seems pretty cool! I couldn't get any support for globbing, however. Not sure if this is a bug, or if it hasn't been implemented yet. I saw that you're using the glob module in package.json, but I was surprised that the CLI didn't offer support for it.

    opened by nfischer 11
  • Adding export command

    Adding export command

    This adds the export command (man page) into the mix.

    Similar to how cash $ alias foo ls succeeds (when it wouldn't succeed in bash), cash $ export FOO $PATH also succeeds in redefining FOO to be $PATH.

    This exports to process.env, which is case insensitive on Windows (even for the new attributes I'm adding). So, on Windows, you can do things like:

    cash $ export FOO='hello'
    cash $ echo $foo
    hello
    

    I don't think there's any good way to avoid this behavior, so until it's a problem, I suggest it be kept.

    This doesn't replace regular assignment. In bash, you can do non-exported assignment of the form: foo=bar, creating a variable named foo with the value "bar". I couldn't figure out a way to write the syntax for regular assignment (posted issue #42 for this).

    @dthree do you have any suggestions for additional tests? I modeled unit tests off the ones for alias.

    opened by nfischer 10
  • Replace lodash with ESX equivalents

    Replace lodash with ESX equivalents

    Typically I avoid bring up the tired discussion of "you might not need underscore," but this project boasts being "written in pure ES6." That being said, when searching through some of the source code I discovered some basic usages of lodash. Curiosity got the best of me so I grepped this directory for usages of lodash and found the following unique cases

    _.extend
    _.filter
    _.isArray
    _.isObject
    _.isString
    _.map
    _.remove
    _.toArray
    

    Usages of extend, filter, isArray, map, remove, and toArray can be replaced by built-in features of JavaScript (some much older than ES6). The others (isString and isObject) have simple, one line equivalents. Are you opposed to removing lodash and using the builtin features? If you're okay with it, I'd can submit a PR.

    opened by blockloop 10
  • Update CI for Node v7

    Update CI for Node v7

    This should be done on both:

    • [x] Travis CI
    • [x] Appveyor

    This should be a very easy change, and it's pretty low-priority. I can knock this out next week, but if anyone else would like to handle it, I can review. I'm self-assigning so I don't forget about it, but ping this thread if you'd like to take it on.

    help wanted 
    opened by nfischer 9
  • Trying to open vim hangs cash

    Trying to open vim hangs cash

    When I type $ vim or $ vim filename, the shell hangs for a few seconds then the window title changes to [NO NAME] - VIM or filename - VIM but vim doesn't open and I can't enter anything into the shell, ctrl+c does nothing. Have I done something wrong or is there an issue here? Possibly related to the node modules hanging to?

    opened by viv-4 9
  • Add support for Environment variables for Unix

    Add support for Environment variables for Unix

    This is related to #22. I noticed that ced6ce6233ebeaa6fa3a82248df83547991fb665 adds support for Windows environment variables, but not for Unix environment variables. This should add that support (although it's not perfect).

    On Unix, if you reference a variable that doesn't exist, it usually defaults to the empty string. So echo $FOO would normally print the empty string. I wrote this to parse similarly.

    This supports the syntax echo $PATH and echo ${PATH}. It doesn't do any of the tricky string manipulation syntax bash offers though.

    I didn't add any tests because I wasn't sure where to add them. If you could point me toward the right spot, I can add those back in. Also, if there's any other issues, I'll gladly do my best to address them.

    opened by nfischer 9
  • feat: add ability to run scripts, and add '-c' flag

    feat: add ability to run scripts, and add '-c' flag

    Fixes #51 and #69 (since they were related).

    Run commands with the -c option:

    > cash -c 'echo hello world'
    hello world
    >
    

    Run scripts like so:

    > cash helloWorldScript.sh
    Hello world!
    

    Also, this adds in the beginning of local variables. This sets the $0, $1, etc. variables as local variables. These variables still aren't exposed to the user, but I can add that functionality in pretty easily by refactoring the preparser a little bit.

    enhancement 
    opened by nfischer 8
  • Execute inline command?

    Execute inline command?

    Not sure how to describe it, so subject might be incorrect.

    Basically what I'm thinking is somewhat like below

    > cash ls
    execute ls, then exit to original shell
    >
    
    > cash cp src dest
    copy...
    > 
    

    let allow invoke specific command. Is there way without installing as global viacash-global?

    opened by kwonoj 8
  • feat: allow external commands on unix

    feat: allow external commands on unix

    External commands were previously limited to Windows. There's no good reason for this, so this adds support for Linux as well.

    Fixes #122 Test: manually tried whoami and git status Test: manually tried a not-found command, verified output looks good

    opened by nfischer 0
  • touch Help screen not showing

    touch Help screen not showing

    When installing cash-touch

    sudo npm install cash-touch -g -force
    

    and running

    > touch --help
    

    I get this error:

    Missing required argument. Showing Help:
    
    sage: touch [options] <files...>
    
      Options:
    
        --help                  output usage information
        -a                      change only the access time
        -c, --no-create         do not create any files
        -d, --date [STRING]     parse STRING and use it instead of current time
        -m                      change only the modification time
        -r, --reference [FILE]  use this file's times instead of current time
        --time [WORD]           change the specified time: WORD is access, atime, or use: equivalent to -a WORD is modify or mtime: equivalent to -m
    

    and it shows the help that is not the /dist/help/touch.js file.

    This error only affects touch, from what I can tell

    opened by ItsJamie9494 0
  • Help screen errors

    Help screen errors

    When running cat --help, I get a Node.js error.

    This error appears on all cash programs, and seems to be related to the parser.

    Error:

    (node:13969) UnhandledPromiseRejectionWarning: undefined
    (node:13969) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
    (node:13969) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    
    opened by ItsJamie9494 4
  • Introducing bash-parser dependency

    Introducing bash-parser dependency

    This is an investigatory PR to study the introduction of a POSIX compliant shell code parser using bash-parser.

    I studied the cash workflow, and I think the majority of changes in source code would concern Vorpal.

    They could be implemented directly there (in vorpal core) or we could patch vorpal and implement it only for cash.

    opened by parro-it 1
Owner
dc
Vorpal, Cash, and other things.
dc
Fabulously kill processes. Cross-platform.

Fabulously kill processes. Cross-platform. Works on macOS, Linux, and Windows. Install $ npm install --global fkill-cli Usage $ fkill --help Usage

Sindre Sorhus 6.7k Jan 4, 2023
Execute shell commands in terminal

Execute shell commands in terminal

skanehira 9 Dec 11, 2021
It is a discord (/) commands bot developed with Discord.js v13.

#Discord.js v13 Slash Bot #Discord Server ?? Setup Run the setup.bat file. Wait until the process is finished. Go to discord.dev page. Create a bot. C

clqu 30 Dec 23, 2022
A slash commands bot using guild commands as a custom commands alternative.

hack-n-slash A slash commands bot using guild commands as a custom commands alternative. This service uses slash-create to handle slash commands and r

Junior 2 Dec 5, 2022
Hacker Tools cross-platform desktop App, support windows/MacOS/LInux ....

Hacker Tools cross-platform desktop App, support windows/MacOS/LInux ....

51pwn 29 Jan 8, 2023
🆙 Upscayl - Free and Open Source AI Image Upscaler for Linux, MacOS and Windows built with Linux-First philosophy.

v1.3 will come around 12 September Upscayl ?? Free and Open Source AI Image Upscaler simplescreenrecorder-2022-08-23_20.17.02.mp4 Upscayl is a cross-p

Upscayl 8.7k Jan 9, 2023
An Anime Game launcher for Linux with automatic patching fixing detection of Linux/Wine and telemetry disabling

An Anime Game launcher for Linux with automatic patching fixing detection of Linux/Wine and telemetry disabling

An Anime Team 367 Jan 4, 2023
🆙 Upscayl - Free and Open Source AI Image Upscaler for Linux, MacOS and Windows built with Linux-First philosophy.

Upscayl ?? Free and Open Source AI Image Upscaler Upsacyl.Demo.mp4 Upscayl is a cross-platform application built with the Linux-first philosophy. This

Upscayl 5.1k Sep 21, 2022
GetOsLocalesCrossPlatform - A cross platform alternative to get locales used on the platform. Works on Node, Electron, NW.js and Browsers

getOsLocalesCrossPlatform A cross platform alternative to get locales used on the platform. Works on Node, Electron, NW.js and Browsers This script is

null 1 Jan 2, 2022
All terminal commands in one place (you can Contribute to it by putting latest commands and adding Readme)

Terminal-Commands All basic terminal commands in one place Show some ❤ by some repositories You can contribute to this readme If you to contribute wit

Shehzad Iqbal 7 Dec 15, 2022
Awesome book with ES6, this project is build using HTML,CSS, JavaScript ES6 the project allows you to add books and save them with the author , for another time checks

Project Name Awsome books Description the project. adding books daynamiclly Built With Major languages Frameworks Technologies used Live Demo (if avai

Alzubair Alqaraghuli 5 Jul 25, 2022
Awesome Books project with ES6 is an application that was built using Vanilla JavaScript with ES6 features like using arrow functions. This application allows you to keep records of your favorite books.

Javascript Project Awesome Books with ES6 Using Javascript to create a simple Awesome Books project. Populating the books list and then removing one b

Ghazanfar Ali 8 Sep 28, 2022
In this project, I restructure my previous Awesome books app code. The goal is to practice ES6 syntax and also make the code more organized by using ES6 modules.

Awesome Books In this project, I will restructure my previous Awesome books app code. The goal is to make it more organized by using modules. I will a

Sidney Kaguli 9 Aug 23, 2022
📗 How to write cross-platform Node.js code

How to write cross-platform Node.js code. Why you should care: according to the 2018 Node.js user survey, 24% of Node.js developers use Windows locall

ehmicky 1.3k Jan 3, 2023
Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.

Onsen UI - Cross-Platform Hybrid App and PWA Framework Onsen UI is an open source framework that makes it easy to create native-feeling Progressive We

null 8.7k Jan 8, 2023
A cross platform high-performance graphics system.

spritejs.org Spritejs is a cross platform high-performance graphics system, which can render graphics on web, node, desktop applications and mini-prog

null 5.1k Dec 24, 2022
Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.

Onsen UI - Cross-Platform Hybrid App and PWA Framework Onsen UI is an open source framework that makes it easy to create native-feeling Progressive We

null 8.7k Jan 4, 2023
Vue Native is a framework to build cross platform native mobile apps using JavaScript

Vue Native Visit our website at vue-native.io or read the official documentation here. Build native mobile apps using Vue Vue Native is a framework to

GeekyAnts 8.4k Jan 6, 2023
Build performant, native and cross-platform desktop applications with native Vue + powerful CSS like styling.🚀

Vue NodeGui Build performant, native and cross-platform desktop applications with Vue. ?? Vue NodeGUI is powered by Vue ?? and Qt5 ?? which makes it C

NodeGui 765 Dec 30, 2022