├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── package-lock.json ├── package.json └── undollar.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled C output 2 | *.out 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | 11 | # Runtime data 12 | pids 13 | *.pid 14 | *.seed 15 | *.pid.lock 16 | 17 | # Directory for instrumented libs generated by jscoverage/JSCover 18 | lib-cov 19 | 20 | # Coverage directory used by tools like istanbul 21 | coverage 22 | 23 | # nyc test coverage 24 | .nyc_output 25 | 26 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 27 | .grunt 28 | 29 | # Bower dependency directory (https://bower.io/) 30 | bower_components 31 | 32 | # node-waf configuration 33 | .lock-wscript 34 | 35 | # Compiled binary addons (http://nodejs.org/api/addons.html) 36 | build/Release 37 | 38 | # Dependency directories 39 | node_modules/ 40 | jspm_packages/ 41 | 42 | # Typescript v1 declaration files 43 | typings/ 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional eslint cache 49 | .eslintcache 50 | 51 | # Optional REPL history 52 | .node_repl_history 53 | 54 | # Output of 'npm pack' 55 | *.tgz 56 | 57 | # Yarn Integrity file 58 | .yarn-integrity 59 | 60 | # dotenv environment variables file 61 | .env 62 | 63 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | *.c 2 | *.out 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Max 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # undollar 2 | 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). 3 | 4 | ## Installation 5 | Simply install undollar as a global package using npm or yarn: 6 | ``` 7 | $ npm install -g undollar 8 | ``` 9 | well, because you haven't installed it yet, 10 | ``` 11 | npm install -g undollar 12 | ``` 13 | 14 | ## Usage 15 | 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. 16 | ``` 17 | neo@computey:~$ $ tar xvfJ something.tar.xz 18 | neo@computey:~$ 19 | neo@computey:~$ echo "It worked! Thanks undollar!" 20 | 21 | ``` 22 | It's as if that stray dollar sign was never there in the first place! 23 | 24 | ## Wait what 25 | 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 "$". 26 | 27 | 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". 28 | 29 | Installing undollar solves this problem, by registering `$` as a valid command, which simply runs everything after that `$`. 30 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "undollar", 3 | "version": "0.0.1", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "undollar", 3 | "version": "1.0.0", 4 | "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).", 5 | "preferGlobal": true, 6 | "bin": { 7 | "$": "./undollar.js" 8 | }, 9 | "main": "undollar.js", 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/ImFeelingDucky/undollar.git" 16 | }, 17 | "keywords": [ 18 | "command-line", 19 | "convenience", 20 | "copy-paste", 21 | "dollar" 22 | ], 23 | "author": "Max Tyrrell", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/ImFeelingDucky/undollar/issues" 27 | }, 28 | "homepage": "https://github.com/ImFeelingDucky/undollar#readme", 29 | "dependencies": {} 30 | } 31 | -------------------------------------------------------------------------------- /undollar.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { spawn } = require('child_process') 4 | 5 | if (!process.argv[2]) { 6 | console.log('Usage: $ command [args] where command is any valid terminal command.') 7 | process.exit() 8 | } 9 | 10 | // Run a command with its arguments by spawning a process and 11 | // transparently routing stdio and signals through this parent process 12 | const spawnedProcess = spawn( 13 | process.argv[2], 14 | process.argv.slice(3), 15 | {stdio: 'inherit'} 16 | ); 17 | 18 | // Route signals through so they still reach the spawned process 19 | process.on('SIGTERM', () => spawnedProcess.kill('SIGTERM')) 20 | process.on('SIGINT', () => spawnedProcess.kill('SIGINT')) 21 | process.on('SIGBREAK', () => spawnedProcess.kill('SIGBREAK')) 22 | process.on('SIGHUP', () => spawnedProcess.kill('SIGHUP')) 23 | 24 | // Exit this process when the spawned process exits 25 | spawnedProcess.on('exit', process.exit) 26 | --------------------------------------------------------------------------------