├── .gitignore ├── bin └── index.js ├── lib └── index.js ├── package.json ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /bin/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var port = process.argv[2]; 4 | var lib = require('../lib'); 5 | 6 | lib.print(port); -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | var qrcode = require("qrcode-terminal"); 2 | var ip = require("ip"); 3 | 4 | module.exports = { 5 | print : function(port) { 6 | var url = "http://" + ip.address(); 7 | 8 | if(port) { 9 | url += ":" + port; 10 | } 11 | 12 | qrcode.generate(url); 13 | } 14 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "local-url-qrcode", 3 | "version": "1.1.0", 4 | "description": "Print URL of your local IP to terminal as a QR code", 5 | "keywords": ["url", "terminal", "local-ip", "qrcode"], 6 | "main": "./lib/index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "bin" : { 11 | "local-url-qrcode" : "./bin/index.js" 12 | }, 13 | "author": "Nick Williams", 14 | "license": "MIT", 15 | "dependencies": { 16 | "ip": "^0.3.2", 17 | "qrcode-terminal": "^0.9.5" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # local-url-qrcode 2 | 3 | Print URL of your local IP to terminal as a QR code. 4 | 5 | ## Why? 6 | 7 | I don't have static local IP. I often want to open a website on my phone during devleopment. I got fed up of looking up my IP, then typing it into the phone's browser. So I slapped this together. 8 | 9 | ## Installation 10 | 11 | Install via npm: 12 | 13 | ```bash 14 | # install locally to use API 15 | npm install local-url-qrcode --save[-dev] 16 | 17 | # install globally to use in CLI via terminal 18 | npm install -g local-url-qrcode 19 | ``` 20 | 21 | ## Usage 22 | 23 | ### API 24 | 25 | ```js 26 | var urlQrcode = require("local-url-qrcode"); 27 | urlQrcode.print(); 28 | ``` 29 | 30 | ### Terminal 31 | 32 | ```bash 33 | local-url-qrcode 34 | ``` 35 | 36 | Port can be supplied as an optional argument: 37 | 38 | ```bash 39 | local-url-qrcode 4000 40 | ``` 41 | 42 | ## Screenshot 43 | 44 | ![Example of URL as QR code output to terminal](http://i.imgur.com/4DcCXmF.png) 45 | 46 | ## License 47 | 48 | Licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php). 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Nick Williams 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 13 | all 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 21 | THE SOFTWARE. --------------------------------------------------------------------------------