Repository: xtyrrell/undollar Branch: master Commit: 27e5f0f87ddc Files: 6 Total size: 5.1 KB Directory structure: gitextract_gsasgdsc/ ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── package.json └── undollar.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Compiled C output *.out # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # Typescript v1 declaration files typings/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env ================================================ FILE: .npmignore ================================================ *.c *.out ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017 Max Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # undollar undollar strips the dollar sign from the beginning of the terminal command you just copied from StackOverflow when you were searching for what arguments to pass to `tar` (`xzf`? `xvfJ`? Or was it `xvf`? You never seem to remember). ## Installation Simply install undollar as a global package using npm or yarn: ``` $ npm install -g undollar ``` well, because you haven't installed it yet, ``` npm install -g undollar ``` ## Usage After you've installed undollar, you can forget it exists. Next time you paste in a command prefixed with a dollar sign, undollar will quietly eat the dollar sign and run the rest of the command. ``` neo@computey:~$ $ tar xvfJ something.tar.xz neo@computey:~$ neo@computey:~$ echo "It worked! Thanks undollar!" ``` It's as if that stray dollar sign was never there in the first place! ## Wait what People often put a "$" in front of a command to indicate that it must be executed on the command line. This is because, on Unix-like operating systems, the command-prompt usually ends in a "$" for non-root users -- so the last thing before a command is a "$". Often when copy-pasting terminal commands from the internet you'll inadvertently end up also having copied the dollar sign at the beginning (especially if you triple-click to select). Trying to execute the command you just pasted will result in some variant of "command not found" or "No such file or directory". Installing undollar solves this problem, by registering `$` as a valid command, which simply runs everything after that `$`. ================================================ FILE: package.json ================================================ { "name": "undollar", "version": "1.0.0", "description": "undollar strips the dollar sign from the beginning of the terminal command you just copied from StackOverflow when you were searching for what arguments to pass to `tar` (`xzf`? `xvfJ`? Or was it `xvf`? You never seem to remember).", "preferGlobal": true, "bin": { "$": "./undollar.js" }, "main": "undollar.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "git+https://github.com/ImFeelingDucky/undollar.git" }, "keywords": [ "command-line", "convenience", "copy-paste", "dollar" ], "author": "Max Tyrrell", "license": "MIT", "bugs": { "url": "https://github.com/ImFeelingDucky/undollar/issues" }, "homepage": "https://github.com/ImFeelingDucky/undollar#readme", "dependencies": {} } ================================================ FILE: undollar.js ================================================ #!/usr/bin/env node const { spawn } = require('child_process') if (!process.argv[2]) { console.log('Usage: $ command [args] where command is any valid terminal command.') process.exit() } // Run a command with its arguments by spawning a process and // transparently routing stdio and signals through this parent process const spawnedProcess = spawn( process.argv[2], process.argv.slice(3), {stdio: 'inherit'} ); // Route signals through so they still reach the spawned process process.on('SIGTERM', () => spawnedProcess.kill('SIGTERM')) process.on('SIGINT', () => spawnedProcess.kill('SIGINT')) process.on('SIGBREAK', () => spawnedProcess.kill('SIGBREAK')) process.on('SIGHUP', () => spawnedProcess.kill('SIGHUP')) // Exit this process when the spawned process exits spawnedProcess.on('exit', process.exit)