[
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: [alexanderepstein]\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "**Issue Label:**\n* [ ] Bug\n* [ ] New feature\n* [ ] Enhancement\n* [ ] New component\n\n**Description:**\n\n\n\n### If its a bug make sure to include this section.\n**OS and OS version:**\n* [ ] Mac\n* [ ] Linux 32 Bit\n* [ ] Linux 64 Bit\n* [ ] Windows 32 Bit\n* [ ] Windows 64 Bit\n\nOS Version:\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "**Pull Request Label:**\n* [ ] Bug\n* [ ] New feature\n* [ ] Enhancement\n* [ ] New component\n* [ ] Typo\n\n**Pull Request Checklist:**\n- [ ] Have you followed the [guidelines for contributing](https://github.com/alexanderepstein/Bash-Snippets/blob/master/CONTRIBUTING.md)?\n- [ ] Have you checked that there aren't other open [pull requests](https://github.com/alexanderepstein/Bash-Snippets/pulls) for the same fix or component?\n- [ ] Have you ran the tests locally with `bats tests`?\n\n-----\n"
  },
  {
    "path": ".github/stale.yml",
    "content": "# Number of days of inactivity before an issue becomes stale\ndaysUntilStale: 175\n# Number of days of inactivity before a stale issue is closed\ndaysUntilClose: 5\n# Issues with these labels will never be considered stale\nexemptLabels:\n  - New Component\n# Label to use when marking an issue as stale\nstaleLabel: Stale\n# Comment to post when marking an issue as stale. Set to `false` to disable\nmarkComment: >\n  This issue has been automatically marked as stale because it has not had\n  recent activity. It will be closed if no further activity occurs. Thank you\n  for your contributions.\n# Comment to post when closing a stale issue. Set to `false` to disable\ncloseComment: >\n  This issue has been automatically closed because it has been \n  inactive for 180 days.\n"
  },
  {
    "path": ".github/workflows/shellcheck.yml",
    "content": "on: push\njobs:\n  shellcheck:\n    name: Shellcheck\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n      - name: Run ShellCheck\n        uses: ludeeus/action-shellcheck@master\n"
  },
  {
    "path": ".gitignore",
    "content": "# IDE\n.idea\n\n# Meta files\n.DS_Store\nThumbs.db"
  },
  {
    "path": ".travis.yml",
    "content": "language: bash\n\nmatrix:\n  include:\n    - os: linux\n      dist: trusty\n      sudo: required\n    - os: osx\n  allow_failures:\n    - os: linux\n\nbefore_install:\n  - sudo ./install.sh all\n  - export TASTE_API_KEY='290044-Taste-QIQUQKOZ'\n\ninstall:\n  - if [ $TRAVIS_OS_NAME = linux ]; then sudo add-apt-repository ppa:duggan/bats --yes; fi\n  - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get update; fi\n  - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -qq bats; else brew install bats; fi\n  - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -qq openssl; else brew install openssl; fi\n\nscript:\n  - bats tests\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment include:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or advances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at epsteina@wit.edu. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]\n\n[homepage]: http://contributor-covenant.org\n[version]: http://contributor-covenant.org/version/1/4/\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing\n\n### First off, thank you for considering contributing to Bash-Snippets.\n\n#### Where do I go from here?\n\nIf you've noticed a bug or have a question, search the <a href=\"https://github.com/alexanderepstein/Bash-Snippets/issues\">issue tracker</a> to see if someone else in the community has already created a ticket. If not, go ahead and <a href=\"https://github.com/alexanderepstein/Bash-Snippets/issues/new\">make one</a>!\n\n#### Otherwise if implementing a fix, feature or new component go through these steps\n#### 1. Fork & Clone The Repository\n* Fork the repository\n* It is assumed you are on either a Unix or Linux system in which are there are no dependencies\n* To download the full source code after forking\n```bash\ngit clone https://github.com/yourusernamehere/Bash-Snippets\n```   \n\n\n#### 2. Implement your fix, feature or new component\n\n###### Fix/Feature\nAt this point, you're ready to make your changes!\n\n###### New Component\n* Decide on a short but sweet name for your tool\n* Create a folder in the Bash-Snippets root directory named after the tool\n* Copy over the Bash-Snippets tool [skeleton](https://github.com/alexanderepstein/Bash-Snippets/blob/master/skeleton) to the newly created folder\n* Rename the skeleton in the new directory to the name of the tool\n* Using newly copied over file as a basis (with the name of your tool) code your new component!\n\nFeel free to ask for help; everyone is a beginner at first :smile_cat:\nMake sure to make your commit messages informative and concise.\n\n\n#### 3. Check The Script Runtime\n\nIf you changed the weather script for example try running it and see if it works as intended. Run ```bats tests``` when inside the Bash-Snippets directory to test the tools.\nIf you added a new script/tool test it to see if it works.\n\n#### 4. Create A Pull Request\n\nFirst make sure to commit and push your changes to your forked repository.\nCheck to see if there are any conflicts with the main repository and your fork.\nIf there are none submit the request and give details as to what you changed or added.\n\n#### 5. Bask In All The Glory Of Adding To A FOSS Application\n![Had to do it to em](https://68.media.tumblr.com/2dfc3369827df9b981e111d7fd8fc732/tumblr_mvemcyarmn1rslphyo1_400.gif)\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 Alex Epstein\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "<div align=\"center\">\n\n# Bash-Snippets\n\n<img src=\"https://cloud.githubusercontent.com/assets/2059754/24601246/753a7f36-1858-11e7-9d6b-7a0e64fb27f7.png\" height=\"250px\" width=\"250px\">\n\n##### A collection of small bash scripts for heavy terminal users with no dependencies\n\n![Version](https://img.shields.io/github/release/alexanderepstein/Bash-Snippets.svg) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a4bf023a3d0d499abc9d2bf14b296a14)](https://www.codacy.com/app/alexanderepstein/Bash-Snippets?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=alexanderepstein/Bash-Snippets&amp;utm_campaign=Badge_Grade) [![Build Status](https://travis-ci.org/alexanderepstein/Bash-Snippets.svg?branch=master)](https://travis-ci.org/alexanderepstein/Bash-Snippets) ![platform](https://img.shields.io/badge/platform-OSX%2C%20Linux%20%26%20Windows-blue.svg)  [![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=plastic)]()\n\n\n\n### All of these scripts have been heavily tested on macOS and Linux\n### Most of these scripts have been tested on Windows 10 and the official developer bash instance. Does not work with Cygwin or Mysys2.\n\n#### Looking for maintainers: I have been and probably will forever be too busy to maintain this properly on my own. I am looking for a few others to help out, if you want to be a maintainer either email me or raise an issue. I will probably only accept maintainers who have made a few contributions (no matter how small) and seem to understand the vision of this project.\n\n</div>\n\n## Tools\n\n<details>\n<summary>Cheat</summary>\n\nThe fastest way to find {command options|code pieces} you need\n\nSupports multiple languages and many bash commands\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/cheat/cheat.png?raw=true\">\n\n</div>\n</details>\n\n<details>\n<summary>Cloudup</summary>\n\nA tool that facilitates backing up github repositories to bitbucket\n\nIf you have ever felt the fear of the github unicorn this could be your savior\n\nFurthermore you can backup the repositories of any github user to your bitbucket.\n\nBackup all github repositories of the designated user at once with the -a option.\nOr run it with no flags and backup individual repositories.\n\n<div align=\"center\">\n\n<img height=\"75%\" width=\"75%\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/cloudup/cloudup.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Crypt</summary>\n\nA wrapper for openssl that allows for quickly encrypting and decrypting files\n\n```bash\ncrypt -e [original file] [encrypted file] # encrypts files\ncrypt -d [encrypted file] [output file] # decrypts files\n```\n#### Encryption Details\n* Uses AES 256 level encryption\n* Key is salted before creation\n* Password is never in plain text, and OpenSSL generates key based on password\n* Encrypted data is encoded in Base64, so it can be used as plain text in an email. (Not usually necessary if attached as a file)\n\n**Tested With**  .pdf, .txt, .docx, .doc, .png, .jpeg\n\n**CAUTION**  Make sure to use different filenames, otherwise your file will be overwritten!\n\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/crypt/crypt.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Cryptocurrency</summary>\n\nConverts Cryptocurrency based on realtime exchange rates of the top 10 cryptos\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"505px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/cryptocurrency/cryptocurrency.png?raw=true\">\n\n</div>\n\nOriginally written by: [Jonas-Taha El Sesiy](https://github.com/elsesiy)\nHeavy modifications by: [Alex Epstein](https://github.com/alexanderepstein)\n</details>\n\n\n<details>\n<summary>Currency</summary>\n\nConverts currency based on realtime exchange rates\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/currency/currency.png?raw=true\">\n\n</div>\n\nIf you want to bypass to guided input you can pass in 3 arguments and it will run from there\nex.```currency [baseCurrency] [exchangeToCurrency] [amountBeingExchanged]```\nso a valid use case would be ```currency USD EUR 12.35```\n</details>\n\n\n<details>\n<summary>Geo</summary>\n\nProvides data for  wan, lan, router, dns, mac, and ip geolocation\n\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/geo/geo.png?raw=true\">\n\n</div>\n\nWritten by: [Jake Meyer](https://github.com/jakewmeyer)\n</details>\n\n<details>\n<summary>Gist</summary>\n\nManage your gist like a pro\n\nClone your owned gists and starred gists as git repos, and Fetch/Create/Edit/Delete them with Github API. It also supports quick search with hashtag and contents.\n\nFor more information, please go through the [guide](gist/README.md)\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/gist/gist.png?raw=true\">\n\n</div>\n\nWritten by: [typebrook](https://github.com/typebrook)\n</details>\n\n<details>\n<summary>Lyrics</summary>\n\nGrab lyrics for a given song quickly from the command line.\n\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/lyrics/lyrics.png?raw=true\">\n\n</div>\n\n</details>\n\n<details>\n<summary>Meme</summary>\n\nA lightning fast meme generator.\n\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/meme/meme.png?raw=true\">\n\n</div>\n\n</details>\n\n<details>\n<summary>Movies</summary>\n\nQuick search that grabs relevant information about a movie\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/movies/movies.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Newton</summary>\n\nPerforms numerical calculations all the way up to symbolic math parsing.\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/newton/newton.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Qrify</summary>\n\nTakes any string of text and turns it into a qr code\n\nThis is useful for sending links or saving a string of commands to your phone\n\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/qrify/qrify.png?raw=true\">\n\n</div>\n\nWritten by: [Linyos Torovoltos](http://github.com/linyostorovovoltos)\n</details>\n\n\n<details>\n<summary>Short</summary>\n\nGets the link that is being masked by a url shortner\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/short/short.png?raw=true\">\n\n</div>\n</details>\n\n<details>\n<summary>Siteciphers</summary>\n\nCheck which ciphers are enabled / disabled for a given https site.\n\nSometimes ciphers are deemed vulnerable, so when you are changing configuration, this can be used to confirm that the cipher truly is disabled.\n\nSome browsers (For example old versions of IE) don't support some of the newer ciphers, which would be a good example of when a SysAdmin would need a list of currently supported ciphers so that changes can be made.\n\n<div align=\"center\">\n\n<img height=\"75%\" width=\"75%\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/siteciphers/siteciphers.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Stocks</summary>\n\nProvides information about a certain stock symbol\n\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/stocks/stocks.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Taste</summary>\n\nRecommendation engine that provides three similar items like the supplied item\n\nAlso can provide information on a given item\n\nValid items are: shows, books, music, artists, movies, authors, games\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/taste/taste.png?raw=true\">\n\n</div>\n\n### Needs an API Key (don't worry it's free)\n* Get the API key [here](https://tastedive.com/account/api_access)\n* After getting the API key run the following line ```export TASTE_API_KEY=\"yourAPIKeyGoesHere\" >> ~/.bash_profile```\n</details>\n\n\n<details>\n<summary>Todo</summary>\n\nA simplistic command line todo list\n\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/todo/todo.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Transfer</summary>\n\nQuickly transfer files from the command line.\n\n\n<div align=\"center\">\n\n<img max-height=\"500px\" max-width=\"500px\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/transfer/transfer.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Weather</summary>\n\nProvides a 3 day forecast\n\nWith no arguments it will grab the weather for your location as determined by your ip\n\n<div align=\"center\">\n\n<img height=\"75%\" width=\"75%\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/weather/weather.png?raw=true\">\n\n</div>\n\nWith arguments you can pass in a city or country and get the weather in that area\n\n\nAlso can show the current moon phase\n\n<div align=\"center\">\n\n<img height=\"75%\" width=\"75%\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/weather/moon.png?raw=true\">\n\n</div>\n</details>\n\n\n<details>\n<summary>Youtube-Viewer</summary>\n\nProvides a way to watch youtube videos from the terminal.\n\nYou can use ```ytview -c [channel name]``` to see recent videos by that artist.\n\nYou can use ```ytview -s [videoToSearch]``` or just ```ytview [videoToSearch]``` to search for videos.\n\n\n<div align=\"center\">\n\n<img height=\"75%\" width=\"75%\" src=\"https://github.com/alexanderepstein/Bash-Snippets/blob/master/ytview/ytview.png?raw=true\">\n\n</div>\n\nWritten by: [Linyos Torovoltos](http://github.com/linyostorovovoltos)\n</details>\n\n## API's Used\n\n<details>\n<summary>All API's</summary>\n\n* To get location based on ip address: [ipinfo](https://ipinfo.io)\n* To get and print weather based on a location: [wttr](http://wttr.in)\n* To grab the stock information in JSON format: [alphavantage](https://www.alphavantage.co)\n* To grab the latest exchange rate between currencies: [fixer](http://fixer.io)\n* To grab information on movies: [omdbapi](http://www.omdbapi.com/)\n* To grab recommendations based on an item: [tastedive](https://tastedive.com)\n* To determine masked link behind url shortner: [ki.tc](http://ki.tc)\n* To grab cheatsheets for commands and languages: [cheat](http://cheat.sh/)\n* To encode text into a qr code: [qrenco](http://qrenco.de)\n* To grab a list of a users repositories: [github](https://developer.github.com/v3/)\n* To upload a repository to bitbucket: [bitbucket](https://developer.atlassian.com/bitbucket/api/2/reference/)\n* To get your WAN ip address: [ipify](https://www.ipify.org/)\n* To grab the latest exchange rate between cryptocurrencies to standard currencies: [coinmarketcap](https://coinmarketcap.com/api/)\n* To perform symbolic math and other computations: [newton](https://newton.now.sh)\n* To transfer files: [transfer](https://transfer.sh)\n* To grab lyrics from a song: [lyrics.ovh](http://docs.lyricsovh.apiary.io)\n* To generate memes: [MemeGen](https://memegen.link)\n* To get a chart of the top 10 cryptocurrencies [rate.sx](http://rate.sx)\n\n</details>\n\n\n## Installing\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/bash-snippets.svg)](https://repology.org/project/bash-snippets/versions)\n\n<details>\n  <summary>AUR</summary>\n  \nbash-snippets is available in two different AUR packages: `bash-snippets` and `bash-snippets-git`.\n\n```bash\nyay -S bash-snippets # or bash-snippets-git\n```\n\n</details>\n\n<details>\n  \n<summary>APT Package Manager</summary>\n\n```bash\nsudo add-apt-repository ppa:navanchauhan/bash-snippets # add bash-snippets PPA\nsudo apt update # update package list\nsudo apt install bash-snippets # install bash-snippets package\n```\n\n</details>\n\n<details>\n  \n  <summary>homebrew (macOS) / linuxbrew (Linux)</summary>\n\n```bash\nbrew install bash-snippets # installs all tools\nbrew install bash-snippets --without-all-tools --with-newton --with-weather # specifying install for individual tools\n```\n\n</details>\n\n<details>\n  \n  <summary>From Source</summary>\n\n```bash\ngit clone https://github.com/alexanderepstein/Bash-Snippets # clone the repository\ncd Bash-Snippets # cd into the cloned directory\ngit checkout v1.23.0 # Git checkout to the latest stable release\n```\n```bash\n./install.sh all # install all scripts\n```\n\nor\n\n```bash\n./install.sh stocks # to install individual scripts\n```\n</details>\n\n## Updating\n\n<details>\n\n<summary>AUR</summary>\n\n```bash\nyay -S bash-snippets # or bash-snippets-git\n```\n</details>\n\n\n<details>\n  \n<summary>APT Package Manager</summary>\n\n```bash\nsudo apt update # update package list\nsudo apt upgrade bash-snippets # upgrade bash-snippets package\n```\n\n</details>\n\n<details>\n  \n<summary>homebrew (macOS) / linuxbrew (Linux)</summary>\n\n```bash\nbrew install bash-snippets --without-all-tools --with-newton --with-weather # specifying install for individual tools\n```\n\n</details>\n\n<details>\n  \n  <summary>From Source</summary>\n\nWith any of the installed tools you can automate the update by running it with the -u option or passing in update as the arguments Ex.\n\n`stocks update`\n\nor\n\n`stocks -u`\n\nThis will clone the repository and install the new versions of scripts that were installed, if you didn’t install a certain tool this script will not install the new version of that tool.\n\n</details>\n\n## Uninstalling\n\n<details>\n  \n  <summary>AUR</summary>\n\n```bash\npacman -Rns bash-snippets # or bash-snippets-git\n```\n\n</details>\n\n<details>\n  \n  <summary>APT Package Manager</summary>\n\n```bash\nsudo apt purge bash-snippets # you can also use remove instead of purge\n```\n\n</details>\n\n<details>\n  \n  <summary>homebrew (macOS) / linuxbrew (Linux)</summary>\n\n```bash\nbrew uninstall bash-snippets\n```\n\n</details>\n\n<details>\n  \n  <summary>Git Uninstall</summary>\n  \n```bash\ngit clone https://github.com/alexanderepstein/Bash-Snippets # If you don't have the Bash-Snippets folder anymore clone the repository\ncd Bash-Snippets # cd into the Bash-Snippets directory:\n```\n\n</details>\n\n<details>\n  \n<summary>To go through a guided uninstall</summary>\n```bash\n./uninstall.sh\n```\n\n##### To uninstall all installed bash-snippets\n```bash\n./uninstall.sh all\n```\n\n##### To go through a guided uninstall\n```bash\n./uninstall.sh\n```\n\n##### To uninstall all installed bash-snippets\n```bash\n./uninstall.sh all\n```\n\n</details>\n\n\n## Donate\nIf this project helped you in any way and you feel like supporting me\n\n[![Donate](https://img.shields.io/badge/Donate-Venmo-blue.svg)](https://venmo.com/AlexanderEpstein)\n[![Donate](https://img.shields.io/badge/Donate-SquareCash-green.svg)](https://cash.me/$AlexEpstein)\n\n###### BTC: 38Q5VbH63MtouxHu8BuPNLzfY5B5RNVMDn\n###### ETH: 0xf7c60C06D298FF954917eA45206426f79d40Ac9D\n###### LTC: LWZ3T19YUk66dgkczN7dRhiXDMqSYrXUV4\n\n#### Inspired by: [Ruby-Scripts](https://github.com/jakewmeyer/Ruby-Scripts)\n\n## License\n\nMIT License\n\nCopyright (c) 2017 Alex Epstein\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n"
  },
  {
    "path": "bak2dvd/bak2dvd",
    "content": "#!/usr/bin/env bash\n# Author: Charles Oblender https://github.com/oblende\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\n\ntarwrite() {\n\ttl=$1\n\tpn=$2\n\ttops=$3\n\t# FreeBSD needs to use gtar\n\t# Make this a function for the addition of a restore option\n    \t# These if statements test for all possible combinations of null strings and executes the permutation\n    \t# of tar or gtar that excludes the null string.\n\t\tif command -v gtar &>/dev/null\n\t\tthen\n            if [[ -z \"$tops\" && -n \"$dir\" && -n \"$excludes\" ]]\n            then\n                gtar -cvpML \"$tl\" -f \"$pn\" \"${dir[@]}\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n            elif [[ -n \"$tops\" && -z \"$dir\" && -n \"$excludes\" ]]\n            then\n                gtar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t    elif [[ -n \"$tops\" && -n \"$dir\" && -z \"$excludes\" ]]\n\t    then\n                gtar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${dir[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t    elif [[ -n \"$tops\" && -z \"$dir\" && -n \"$excludes\" ]]\n\t    then\n                gtar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t    elif [[ -n \"$tops\" && -z \"$dir\" && -z \"$excludes\" ]]\n\t    then\n                gtar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t    elif [[ -z \"$tops\" && -z \"$dir\" && -n \"$excludes\" ]]\n\t    then\n                gtar -cvpML \"$tl\" -f \"$pn\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t    elif [[ -z \"$tops\" && -z \"$dir\" && -z \"$excludes\" ]]\n\t    then\n                gtar -cvpML \"$tl\" -f \"$pn\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t    else\n                gtar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${dir[@]}\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t    fi\n    fi\n\n\tif command -v tar &>/dev/null\n        then\n            if [[ -z \"$tops\" && -n \"$dir\" && -n \"$excludes\" ]]\n            then\n                tar -cvpML \"$tl\" -f \"$pn\" \"${dir[@]}\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n            elif [[ -n \"$tops\" && -z \"$dir\" && -n \"$excludes\" ]]\n            then\n                tar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t    elif [[ -n \"$tops\" && -n \"$dir\" && -z \"$excludes\" ]]\n\t    then\n                tar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${dir[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t    elif [[ -n \"$tops\" && -z \"$dir\" && -n \"$excludes\" ]]\n\t    then\n                tar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t    elif [[ -n \"$tops\" && -z \"$dir\" && -z \"$excludes\" ]]\n\t    then\n                tar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t    elif [[ -z \"$tops\" && -z \"$dir\" && -n \"$excludes\" ]]\n\t    then\n                tar -cvpML \"$tl\" -f \"$pn\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t    elif [[ -z \"$tops\" && -z \"$dir\" && -z \"$excludes\" ]]\n\t    then\n                tar -cvpML \"$tl\" -f \"$pn\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t   else\n                tar -cvpML \"$tl\" -f \"$pn\" \"$tops\" \"${dir[@]}\" \"${excludes[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n        fi\n    fi\n\n\n}\n\ntarread() {\n\tpn=$1\n\ttops=$2\n    # These if statements test for null strings and then excutes the permutation of tar or gtar\n    # that excludes the null strings.\n\tif command -v gtar &>/dev/null\n\tthen\n            if [[ -n \"$tops\" && -n \"$dir\" && -z \"$filenames\" ]]\n            then\n                gtar -xvpMf \"$pn\" \"$tops\" \"${dir[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n            elif [[ -n \"$tops\" && -z \"$dir\" && -n \"$filenames\" ]]\n            then\n                gtar -xvpMf \"$pn\" \"$tops\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t\t\telif [[ -n \"$tops\" && -z \"$dir\" && -z \"$filenames\" ]]\n            then\n                gtar -xvpMf \"$pn\" \"$tops\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t\t\telif [[ -z \"$tops\" && -n \"$dir\" && -n \"$filenames\" ]]\n            then\n                gtar -xvpMf \"$pn\" \"${dir[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t\t\telif [[ -z \"$tops\" && -n \"$dir\" && -z \"$filenames\" ]]\n            then\n                gtar -xvpMf \"$pn\" \"${dir[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t\t\telif [[ -z \"$tops\" && -z \"$dir\" && -n \"$filenames\" ]]\n            then\n                gtar -xvpMf \"$pn\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n\t\t\treturn\n\t\t\telif [[ -z \"$tops\" && -z \"$dir\" && -z \"$filenames\" ]]\n            then\n                gtar -xvpMf \"$pn\" <&7 &\n                tarpid=$!\n                countlimit=2\n                return\n\t\t\telse\n                gtar -xvpMf \"$pn\" \"$tops\" \"${dir[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=2\n\t\t\treturn\n\t\tfi\n    fi\n\n\t\tif command -v tar &>/dev/null\n\t\tthen\n\t\tif [[ -n \"$tops\" && -n \"$dir\" && -z \"$filenames\" ]]\n            then\n                tar -xvpMf \"$pn\" \"$tops\" \"${dir[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n            elif [[ -n \"$tops\" && -z \"$dir\" && -n \"$filenames\" ]]\n            then\n                tar -xvpMf \"$pn\" \"$tops\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t\t\telif [[ -n \"$tops\" && -z \"$dir\" && -z \"$filenames\" ]]\n            then\n                tar -xvpMf \"$pn\" \"$tops\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t\t\telif [[ -z \"$tops\" && -n \"$dir\" && -n \"$filenames\" ]]\n            then\n                tar -xvpMf \"$pn\" \"${dir[@]}\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t\t\telif [[ -z \"$tops\" && -n \"$dir\" && -z \"$filenames\" ]]\n            then\n                tar -xvpMf \"$pn\" \"${dir[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t\t\telif [[ -z \"$tops\" && -z \"$dir\" && -n \"$filenames\" ]]\n            then\n                tar -xvpMf \"$pn\" \"${filenames[@]}\" <&7 &\n                tarpid=$!\n                countlimit=1\n\t\t\treturn\n\t\t\telif [[ -z \"$tops\" && -z \"$dir\" && -z \"$filenames\" ]]\n            then\n                tar -xvpMf \"$pn\" <&7 &\n                tarpid=$!\n                countlimit=1\n                return\n\t    else\n\t\t tar -xvpMf \"$pn\" \"$tops\" \"${dir[@]}\" \"{$filenames[@]}\" <&7 &\n             \ttarpid=$!\n             \tcountlimit=1\n\t    fi\n    fi\n}\n\ndiscread() {\n\tdev=$1\n\tpn=$2\n\ttpid=$3\n\tcounter=$4\n\tcountlim=$5\n\trl=$6\n    # FreeBSD is a brain damaged OS written by brain damaged developers who, when given a choice, will run headlong into\n    # making a task or operation as difficult as possible.\n    if [[ $(uname | grep \"FreeBSD\" | wc -l) -gt 0 ]]\n    then\n        while [ \"$counter\" -eq \"$countlim\" ]\n        do\n            dd if=\"$dev\" of=\"$pn\" bs=2048\n            eject \"$dev\"\n            counter=0\n            counter=$(ps -A | grep $tarpid | wc -l)\n            if [[ $counter -eq $countlim ]]\n            then\n                echo\n                read -p \"Insert next disc and press Enter:\" response\n                echo \"$response\" >&7\n            fi\n        done\n    else\n        while [ \"$counter\" -eq \"$countlim\" ]\n        do\n            dd if=\"$dev\" of=\"$pn\" bs=1k count=\"$rl\"\n            eject \"$dev\"\n            counter=0\n            counter=$(ps -A | grep $tarpid | wc -l)\n            if [[ $counter -eq $countlim ]]\n            then\n                read -p \"Insert next disc and press Enter:\" response\n                echo \"$response\" >&7\n            fi\n        done\n    fi\n}\n\ndvdburn() {\n\tcounter=$4\n\tcountlim=$5\n\taltburn=$6\n\twhile [ \"$counter\" -eq \"$countlim\" ]\n\tdo\n\t\tif [[ $(echo \"$1\" | grep \"dev\" | wc -l) -eq 0 ]]\n\t\tthen\n\t\t\techo \"DVD or BluRay burning requires device from /dev.\"\n\t\t\texitcode=1\n\t\t\tcleanup $exitcode\n\t\tfi\n\t\t# Growisofs is untrustworthy for DL media, and is slow for BD-RE/DVD-RAM media because of defect management.\n\t\t\tcase \"$altburn\" in\n\t\t\t\tcdrskin)\n                    \t\t\t# cdrskin doesn't like -multi when burning BD-R media.\n\t\t\t\t\t# BD-RE media needs to be formatted before recording\n\t\t\t\t\tcdrskin dev=\"$1\" blank=as_needed stream_recording=on driveropts=burnfree -tao -eject -data \"$2\"\n\t\t\t\t\t;;\n\t\t\t\txorrecord)\n\t\t\t\t\txorrecord dev=\"$1\" blank=as_needed stream_recording=on driveropts=burnfree -tao -multi -eject -data \"$2\"\n\t\t\t\t\t;;\n\t\t\t\t*)\n\t\t\t\t\tgrowisofs -Z \"$1\"=\"$2\"\n\t\t\tesac\n        \tcounter=0\n        \tcounter=$(ps -A | grep \"$3\" | wc -l)\n        \tif [[ $counter -eq $countlim ]]\n        \tthen\n                \tread -p \"Insert next disc and press Enter:\" response\n                \techo \"$response\" >&7\n        \tfi\n\tdone\n# dvd-r restore needs tracklen + 4. Need to check +r single and dual layer as well as bd medias. Joy.\n# DVD+R needs no compensation.\n}\n\ncdburn() {\n\tcounter=$4\n\tcountlim=$5\n\tcdb=$6\n\twhile [ \"$counter\" -eq \"$countlim\" ]\n\tdo\n\t\tif [[ $(uname | grep \"FreeBSD\" | wc -l) -gt 0 ]]\n\t\tthen\n\t\t\tif [[ $(echo \"$1\" | grep \"dev\" | wc -l) -gt 0 && $(echo \"$cdb\" | grep \"cdrecord\" | wc -l) -gt 0 ]]\n\t\t\tthen\n\t\t\t\techo \"CD burning requires SCSI address in the form of b,t,l. Please use cdrecord -scanbus for a list of possible SCSI addresses.\"\n\t\t\t\texitcode=1\n\t\t\t\tcleanup $exitcode\n\t\t\tfi\n\t\telif [[ $(uname | grep \"Linux\" | wc -l) -gt 0 ]]\n\t\tthen\n\t\t\tif [[ $(echo \"$1\" | grep \"dev\" | wc -l) -eq 0 ]]\n\t\t\tthen\n\t\t\t\t# Chances are if it's Linux then wodim is being used and requires /dev/srX instead of SCSI address\n\t\t\t\techo \"CD burning in Linux with cdrecord or wodim requires device from /dev.\"\n\t\t\t\texitcode=1\n\t\t\t\tcleanup $exitcode\n\t\t\tfi\n\t\tfi\n\t\tcase \"$cdb\" in\n\t\t\tcdrecord)\n\t\t\t\tcdrecord dev=\"$1\" driveropts=burnfree -tao -multi -eject -data \"$2\" #Turned burnfree on just in case. Restore needs tracklen + 8\n\t\t\t\t;;\n\t\t\twodim)\n\t\t\t\twodim dev=\"$1\" driveropts=burnfree -tao -multi -eject -data \"$2\"\n\t\t\t\t;;\n\t\t\tcdrskin)\n\t\t\t\tcdrskin dev=\"$1\" driveropts=burnfree -tao -multi -eject -data \"$2\"\n\t\t\t\t;;\n\t\t\txorrecord)\n\t\t\t\txorrecord dev=\"$1\" driveropts=burnfree -tao -multi -eject -data \"$2\"\n\t\t\t\t;;\n\t\tesac\n\n\t\tcounter=0\n\t\tcounter=$(ps -A | grep \"$3\" | wc -l)\n\t\tif [[ $counter -eq $countlim ]]\n\t\tthen\n\t\t\tread -p \"Insert next disc and press Enter:\" response\n\t\t\techo \"$response\" >&7\n\t\tfi\n\tdone\n}\n\ncleanup() {\n\tkill $tarpid &>/dev/null\n\trm \"$pipename\"\n\trm \"$fifoname\"\n\n\texit \"$1\"\n}\n\ngetCDburner() {\n\n\tif command -v cdrecord &>/dev/null\n\tthen\n\t\tcdburner=\"cdrecord\"\n\t\treturn\n\tfi\n\tif command -v wodim &>/dev/null\n\tthen\n\t\tcdburner=\"wodim\"\n\t\treturn\n\tfi\n\tif command -v cdrskin &>/dev/null\n\tthen\n\t\tcdburner=\"cdrskin\"\n\t\treturn\n\tfi\n\tif command -v xorrecord &>/dev/null\n\tthen\n\t\tcdburner=\"xorrecord\"\n\t\treturn\n\tfi\n\n}\n# This function finds an alternative burner to growisofs if DVD-DL, DVD-RAM, or BD-R(E) media is chosen to improve speed\n# or to actually write a full dataset in the case of DVD-DL media.\ngetAltDVDburner() {\n\n\tif command -v cdrskin &>/dev/null\n\tthen\n\t\taltdvdburner=\"cdrskin\"\n\t\treturn\n\tfi\n\tif command -v xorrecord &>/dev/null\n\tthen\n\t\taltdvdburner=\"xorrecord\"\n\t\treturn\n\telse\n        echo \"To burn DVD-DL or BD media xorriso or cdrskin needs to be installed.\"\n        echo \"I can burn using growisofs, but it may not burn DVD-DL media correctly or will burn BD-RE media very slowly.\"\n        read -p \"If you wish to continue using growisofs then type YES then press [Enter], else just press [Enter] to abort: \" yesno\n        if [[ \"$yesno\" -eq \"YES\" ]]\n        then\n            if command -v growisofs &>/dev/null\n            then\n                altdvdburner=\"growisofs\"\n            fi\n        else\n            exitcode=1\n            cleanup $exitcode\n        fi\n    fi\n}\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 1.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        git clone \"https://github.com/$githubUserName/$repositoryName\" || { echo \"Couldn't download latest version\"; exit 1; }\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nusage()\n{\n  cat <<EOF\nBak2dvd\nDescription: A script to write tar archives to optical disc.\nUsage: bak2dvd [flags] -t \"[arguments]\"\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\n  -d  Sets the optical drive to use\n  -C Change to directory\n  -a Include file or directory into archive\n  -t  Parameters to pass to tar\n  -w Write to optical media\n  -X Exclude file or directory from archive\n  -r  Restore from optical media\n\n Disc technology flags are:\n\n  -cd       for cd-rom\n  -dvd      for single layer DVD+R\n  -dvd-dl   for dual layer DVD+R\n  -dvd-r    for single layer DVD-R\n  -dvd-ram  for those who have it\n  -bd       for single layer BluRay\n  -bd-dl    for dual layer BluRay\n\n Preset tar parameters are -cvpML and -f\n\nExample:\n\nTo Write:\n   bak2dvd -w -d /dev/optical -dvd -C $HOME -a Documents -a \"Library Files\"\n   bak2dvd -w -d 1,0,0 -cd -C $HOME -a Documents -a \"Library Files\"\n\nTo Restore:\n   bak2dvd -r -d /dev/optical -dvd -C $HOME\nEOF\n}\n\n\noptions=0\ndeclare -i tracklen\ndeclare -i comp\ndeclare -i rw\ndeclare -a dir\ndeclare -a filenames\ndir=\"\"\nfilenames=\"\"\ncdburner=\"\"\naltdvdburner=\"\"\ndevice=\"\"\ntaropts=\"\"\n\nwhile test $# -gt 0; do\n  case \"$1\" in\n    \\?) echo \"Invalid option: -$1\" >&2\n        exit 1\n        ;;\n   -h|--help)  usage\n        exit 0\n        ;;\n    -v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    -u|update)\n\tgetConfiguredClient || exit 1\n        checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    -d)\n\tshift\n\tif test $# -gt 0; then\n\t\tdevice=$1\n\telse\n\t\techo \"No optical device specified\" >&2\n\t\texit 1\n\tfi\n\tshift\n\toptions=1\n\t;;\n     -dvd)\n\t\ttracklen=4580000 # DVD+R capacity - 10M\n\t\tcomp=0\n\t\tshift\n\t\toptions=1\n\t\t;;\n    -dvd-ram)\n        # DVD-RAM for those who have this under appreciated, and under utilized media format\n        tracklen=4463168 # DVD-RAM capacity - 10M\n        comp=2\n        shift\n        getAltDVDburner # Media has same defect management as BD-RE. In fact you might call it the orginal.\n        options=1\n        ;;\n     -dvd-dl)\n\t\ttracklen=8337408 # DVD+R DL capacity - 10M\n\t\tcomp=2\n\t\tshift\n\t\tgetAltDVDburner\n\t\toptions=1\n\t\t;;\n     -dvd-r)\n\t\ttracklen=4585536 #DVD-R single layer capacity -10M\n\t\tcomp=4\n\t\tshift\n\t\toptions=1\n\t\t;;\n     -bd)\n\t\ttracklen=24166400 # This should be 10M less than total. Had miscalculated, now correct.\n\t\tcomp=0\n\t\tshift\n\t\tgetAltDVDburner # While growisofs canb be trusted, it'll be slow with *any* bd-re media because of defect management.\n\t\toptions=1\n\t\t;;\n     -bd-dl)\n\t\ttracklen=47294464 #same as above but dual layer\n\t\tcomp=6\n\t\tshift\n\t\tgetAltDVDburner\n\t\toptions=1\n\t\t;;\n     -cd)\n\t\ttracklen=712702 #700M cd-rom capacity - 4k, 10M is not an insigficant amount at this storage capacity!\n\t\tcomp=8\n\t\tshift\n\t\tgetCDburner\n\t\toptions=1\n\t\t;;\n    -a)\n        shift\n        if test $# -gt 0; then\n            filenames=( \"${filenames[@]}\" \"$1\" )\n        else\n            echo \"No filename or directory specified\" >&2\n            exit 1\n        fi\n        shift\n        ;;\n    -C)\n            shift\n            if test $# -gt 0; then\n            dir=( \"-C\" )\n            dir=( \"${dir[@]}\" \"$1\" )\n        else\n            echo \"No directory specified.\" >&2\n            exit 1\n        fi\n        shift\n        ;;\n     -t)\n\t\tshift\n\t\tif test $# -gt 0; then\n\t\t\ttaropts=$1\n\t\telse\n\t\t\techo \"No options to tar specified.\" >&2\n\t\t\texit 1\n\t\tfi\n\t\tshift\n\t\toptions=1\n\t\t;;\n     -r)\n\t\trw=2\n\t\tshift\n\t\t;;\n     -w)\n\t\trw=1\n\t\tshift\n\t\t;;\n    -X)\n        shift\n        if test $# -gt 0; then\n            excludes=( \"${excludes[@]}\" \"--exclude=\" )\n            excludes=( \"${excludes[@]}\"\"$1\" )\n        else\n            echo \"No excluded file or directory specified.\"\n            exit 1\n        fi\n        shift\n        ;;\n    :)  echo \"Option -$1 requires an argument.\" >&2\n        exit 1\n        ;;\n    *)\n        echo \"Something bad happened or malformed arguments.\"\n        exit 1\n        ;;\n  esac\ndone\n\n# special set of first arguments that have a specific behavior across tools\nif [[ $# == \"0\" && $options == \"0\" ]]; then\n  usage ## if calling the tool with no flags and args chances are you want to return usage\n  exit 0\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"update\" ]]; then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    update || exit 1\n    exit 0\n  elif [[ $1 == \"help\" ]]; then\n    usage\n    exit 0\n  fi\nfi\n\n## The rest of the conditions and code would go here\n## Make sure to use checkInternet at least once before any time httpGet will be called.\n## Make sure to call getConfiguredClient at least once before ever calling checkInternet.\ntrap \"cleanup 2\" 2\npipename=\"/tmp/$RANDOM.pipe\"\nfifoname=\"/tmp/$RANDOM.fifo\"\n#changed from mknod to mkfifo to  make script more cross platform\nmkfifo $pipename\nmkfifo $fifoname\ntarpid=\"\"\n# Asign the fifo to a file descriptor. No need for ugly cat hack, and it actually works!\nexec 7<>$fifoname\ndeclare -i readlen\ncountlimit=\"\"\n# If no -d option was set then the script will be able to get this far, but will be stopped \n# otherwise confusing errors will happen. May change to give the user a chance to specify a device or quit at this point.\nif [[ -z \"$device\" ]]\nthen\n    echo \"No device specified.\"\n    exitcode=1\n    cleanup $exitcode\nfi\n\nif [[ $rw -eq 1 ]]\nthen\n\ttarwrite $tracklen $pipename \"$taropts\"\nelif [[ $rw -eq 2 ]]\nthen\n\treadlen=$tracklen+$comp\n\ttarread $pipename \"$taropts\"\nfi\n\ncount=$(ps -A | grep \"$tarpid\" | wc -l)\n# Check that tar is alive and prompt for media\nif [[ $count -eq $countlimit ]]\nthen\n\tread -p \"Insert media and press Enter:\"\n\tif [[ $rw -eq 1 ]]\n\tthen\n\t\t#call appropriate burning function here. Want to add support for mini CD's and mini DVD's at some point.\n\t\tif [[ $tracklen -le 712702 ]]\n\t\tthen\n\t\t\tcdburn \"$device\" $pipename \"$tarpid\" \"$count\" \"$countlimit\" \"$cdburner\"\n\t\telse\n\t\t\tdvdburn \"$device\" $pipename \"$tarpid\" \"$count\" \"$countlimit\" \"$altdvdburner\"\n\t\tfi\n\telif [[ $rw -eq 2 ]]\n\tthen\n\t\tdiscread \"$device\" $pipename \"$tarpid\" \"$count\" \"$countlimit\" $readlen\n    else\n        echo \"You need to specify option -w for writing a backup or -r for restoring from backup.\"\n        exitcode=1\n        cleanup $exitcode\n\tfi\n\nelse\n\t# otherwise something has gone wrong and we need to stop\n\techo\n\techo \"Tar has died unexpectedly.\" >&2\n\t# Call cleanup function here\n\texitcode=1\n\tcleanup $exitcode\nfi\nexitcode=0\ncleanup $exitcode\n# This exit is a sheet anchor. It probably isn't needed, but it makes me feel better.\nexit 0\n"
  },
  {
    "path": "bash-snippets/bash-snippets",
    "content": "#!/usr/bin/env bash\n# Author: Navan Chauhan and Alexander Epstein\ndeclare -a tools=(bak2dvd cheat cloudup crypt cryptocurrency currency geo lyrics meme movies newton pwned qrify short siteciphers stocks taste todo transfer weather ytview)\ndeclare -a validTools=()\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\n\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ngrablatestversion()\n{\n  repositoryName=\"Bash-Snippets\"\n  githubUserName=\"alexanderepstein\"\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nheader()\n{\n  title=\"Bash Snippets\"\n  installver=\"Installed Version: $currentVersion\"\n  latestver=\"Latest Version: $latestVersion\"\n  printf \"\\t\\t\\t\\t     %s\\n\" \"$title\"\n  printf \"\\t\\t%s\\t\\t%s\\n\" \"$latestver\" \"$installver\"\n}\n\n\ntoolMenu()\n{\n  while true; do\n    clear\n    header\n    count=1\n    for command in \"${validTools[@]}\"; do\n      if [[ $count -gt 9 ]];then c=$count\n      else c=\"0$count\"; fi\n      spaces=$((40 - $(echo \"$command\" | wc -c)))\n      echo -n -e \"\\t\\t\\t$c.\"\n      for (( i = 0 ; i < $spaces; i++)) ;do\n        printf \" \"\n      done\n      echo \"$command\"\n      count=$(( $count + 1 ))\n    done\n    echo -e -n \"\\t\\tChoose a tool or just press enter to go back: \"\n    read choice\n    if [[ $choice == \"\" ]];then clear; header; break; fi\n    echo -e -n \"\\t\\tEnter any arguments you want to use with the tool: \"\n    read args\n    clear\n    if [[ $choice =~ [0-9] ]]; then ${validTools[$(($choice-1))]} \"$args\"\n    else $choice \"$args\"; fi\n    exit 0\n  done\n}\n\nmenu()\n{\n  while true; do\n    echo -e \"\\t\\t\\t01.\\t\\t\\t\\tTools\"\n    echo -e \"\\t\\t\\t02.\\t\\t\\t\\tInstallation Check\"\n    echo -e \"\\t\\t\\t03.\\t\\t\\t\\tView man page\"\n    echo -e \"\\t\\t\\t04.\\t\\t\\t\\tUpdate\"\n    echo -e \"\\t\\t\\t05.\\t\\t\\t\\tDonate\"\n    echo -e \"\\t\\t\\t06.\\t\\t\\t\\tQuit\"\n    echo -e -n \"\\n\\t\\t\\tChoose an option: \"\n    read choice\n    if [[ $choice -gt 6 || $choice -lt 1 ]];then\n      echo \"Error invalid option!\"\n      sleep 2\n      clear\n      header\n      continue\n    fi\n    clear\n    header\n    if   [[ $choice -eq 1 ]];then toolMenu\n    elif [[ $choice -eq 2 ]];then installationcheck\n    elif [[ $choice -eq 3 ]];then man bash-snippets\n    elif [[ $choice -eq 4 ]];then\n      ${validTools[1]} -u\n      sleep 2\n      clear\n      header\n    elif [[ $choice -eq 5 ]];then\n      clear\n      echo -e \"\\t\\tThanks for thinking of donating, that's pretty cool of you\"\n      echo -e \"\\n\\t\\tCryptocurrency Donation Addresses\"\n      echo -e \"\\t\\t\\tBTC: 38Q5VbH63MtouxHu8BuPNLzfY5B5RNVMDn\"\n      echo -e \"\\t\\t\\tETH: 0xf7c60C06D298FF954917eA45206426f79d40Ac9D\"\n      echo -e \"\\t\\t\\tLTC: LWZ3T19YUk66dgkczN7dRhiXDMqSYrXUV4\\n\"\n      echo -e \"\\t\\tNormal Methods\"\n      echo -e \"\\t\\t\\tVenmo: AlexanderEpstein\"\n      echo -e \"\\t\\t\\tSquare Cash: AlexEpstein\\n\\n\\n\\n\"\n      exit 0\n    elif [[ $choice -eq 6 ]]; then clear; exit 0\n    fi\n  done\n}\n\ninstallationcheck()\n{\n  validTools=()\n  for tool in \"${tools[@]}\"; do\n    if [ -e \"/usr/local/bin/$tool\" ]; then\n      state=\"present\";\n      start=51;\n      validTools+=($tool);\n    else state=\"absent\"; start=52; fi\n      if $1; then\n        echo -n -e \"\\t\\t$tool\"\n        spaces=$(($start - $( echo \"$tool\" | wc -c)))\n        for (( i = 0 ; i < $spaces; i++)) ;do\n          printf \" \"\n        done\n        echo $state\n      fi\n  done\n  if $1; then\n    echo -n \"Press enter to go back to the menu\"\n    read\n    clear\n    header\n  fi\n}\n\nif [[ $# -eq 0 ]]; then\n  clear\n  checkInternet\n  getConfiguredClient\n  grablatestversion\n  header\n  installationcheck false\n  echo\n  menu\nelif [[ $# -eq 1 ]]; then\n  if [[ $1 == \"-u\" || $1 == \"update\" ]]; then\n    installationcheck false\n    ${validTools[1]} -u\n  elif [[ $1 == \"-h\" || $1 == \"help\" ]]; then man bash-snippets\n  elif [[ $1 == \"-v\" ]]; then echo \"Version $currentVersion\"\n  fi\n\nfi\n"
  },
  {
    "path": "bash-snippets.1",
    "content": ".\\\" generated with Ronn/v0.7.3\n.\\\" http://github.com/rtomayko/ronn/tree/0.7.3\n.\n.TH \"BASH\\-SNIPPETS\" \"1\" \"April 2020\" \"\" \"\"\n.\n.SH \"NAME\"\n\\fBbash\\-snippets\\fR \\- A collection of small bash scripts for heavy terminal users\n.\n.SH \"Tools\"\n.\n.SS \"Cheat\"\nDescription: Cheatsheets for quick information about multiple programming languages along with terminal commands\n.\n.P\nUsage: cheat [flags] [command] or cheat [flags] [programming language] [subject]\n.\n.IP \"\\(bu\" 4\n\\-s Does a search for last argument rather than looking for exact match\n.\n.IP \"\\(bu\" 4\n\\-i Case insensitive search\n.\n.IP \"\\(bu\" 4\n\\-b Word boundaries in search\n.\n.IP \"\\(bu\" 4\n\\-r Recursive search\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nSpecial Pages:\n.\n.IP \"\\(bu\" 4\nhello Describes building the hello world program written in the language\n.\n.IP \"\\(bu\" 4\nlist This lists all cheatsheets related to previous arg if none it lists all cheatsheets\n.\n.IP \"\\(bu\" 4\nlearn Shows a learn\\-x\\-in\\-minutes language cheat sheet perfect for getting started with the language\n.\n.IP \"\\(bu\" 4\n1line A collection of one\\-liners in this language\n.\n.IP \"\\(bu\" 4\nweirdness A collection of examples of weird things in this language\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\ncheat rust hello\n.\n.IP \"\\(bu\" 4\ncheat \\-r \\-b \\-i go\n.\n.IP \"\\(bu\" 4\ncheat julia Functions\n.\n.IP \"\\(bu\" 4\ncheat \\-i go operators\n.\n.IP \"\" 0\n.\n.SS \"Cloudup\"\nDescription: Backs up a users github repositories to your bitbucket account\\. With no flags cloudup will guide you through backing up a single repository\n.\n.P\nUsage: cloudup [flags] or cloudup [flags] [listOfGHRepoNamesSplitBySpaces]\n.\n.IP \"\\(bu\" 4\n\\-p Upload the repositor(y)(ies) as private to bitbucket (must have private repo ability on bitbucket)\n.\n.IP \"\\(bu\" 4\n\\-a Backup all github repositories\n.\n.IP \"\\(bu\" 4\n\\-s Only backup repositories that you have created (no forks) (only works in conjunction with the \\-a flag)\n.\n.IP \"\\(bu\" 4\n\\-t Backup the repository with a timestamp added to the repostiory name (will always create a new unique bitbucket repo)\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\ncloudup\n.\n.IP \"\\(bu\" 4\ncloudup \\-p \\-a\n.\n.IP \"\\(bu\" 4\ncloudup \\-p nameOfRepo1 nameOf Repo2\n.\n.IP \"\\(bu\" 4\ncloudup nameOfRep\n.\n.IP \"\" 0\n.\n.SS \"Crypt\"\nDescription: A wrapper around openssl that facilitates encrypting and decrypting files\\.\n.\n.P\nUsage: crypt [flag] [inputFile] [outputFile]\n.\n.IP \"\\(bu\" 4\n\\-e Encrypt the inputFile and store it in the outputFil\n.\n.IP \"\\(bu\" 4\n\\-d Decrypt the inputFile and store it in the outputFil\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\ncrypt \\-e mySecretFile\\.txt myEncryptedFile\\.jpg (change filetype so default program is incorrect)\n.\n.IP \"\\(bu\" 4\ncrypt \\-d myEncryptedFile\\.jpg thisIsNowDecrypted\\.txt (change filetype back so now default program is correct)\n.\n.IP \"\" 0\n.\n.SS \"CryptoCurrency\"\nDescription: A realtime cryptocurrency converter\\. With no flags it will pull down the latest stats of the top 10 cryptos\n.\n.P\nUsage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [flag] [arg]\n.\n.IP \"\\(bu\" 4\n\\-o Utilize the old functionality of the tool\n.\n.IP \"\\(bu\" 4\n\\-f Fiat currency for conversions\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples: cryptocurrency \\-o cryptocurrency \\-f eur\n.\n.SS \"Currency\"\nDescription: A realtime currency converter\\. With no flags it will guide you through the currency exchange\n.\n.P\nUsage: currency or currency [flag] or currency [base] [exchangeTo] [amount]\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nSupported Currencies:\n.\n.P\n| AUD | BGN | BRL | CAD | | CHF | CNY | CZK | DKK | | EUR | GBP | HKD | HRK | | HUF | IDR | ILS | INR | | JPY | KRW | MXN | MYR | | NOK | NZD | PHP | PLN | | RON | RUB | SEK | SGD | | THB | TRY | USD | ZAR |\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\ncurrency EUR USD 12\\.35\n.\n.IP \"\\(bu\" 4\ncurrency\n.\n.IP \"\" 0\n.\n.SS \"Geo\"\nDescription: Provides quick access for wan, lan, router, dns, mac, and ip geolocation data\n.\n.P\nUsage: geo [flag]\n.\n.IP \"\\(bu\" 4\n\\-w Returns WAN IP\n.\n.IP \"\\(bu\" 4\n\\-l Returns LAN IP(s)\n.\n.IP \"\\(bu\" 4\n\\-r Returns Router IP\n.\n.IP \"\\(bu\" 4\n\\-d Returns DNS Nameserver\n.\n.IP \"\\(bu\" 4\n\\-m Returns MAC address for interface\\. Ex\\. eth0\n.\n.IP \"\\(bu\" 4\n\\-g Returns Current IP Geodata\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\ngeo \\-g\n.\n.IP \"\\(bu\" 4\ngeo \\-wlrdgm eth0\n.\n.IP \"\" 0\n.\n.P\nCustom Geo Output => [all] [query] [city] [region] [country] [zip] [isp]\n.\n.P\nExample: geo \\-a 8\\.8\\.8\\.8 \\-o city,zip,isp\n.\n.IP \"\\(bu\" 4\n\\-o [options] Returns Specific Geodata\n.\n.IP \"\\(bu\" 4\n\\-a [address] For specific ip in \\-s\n.\n.IP \"\\(bu\" 4\n\\-v Returns Version\n.\n.IP \"\\(bu\" 4\n\\-h Returns Help Screen\n.\n.IP \"\\(bu\" 4\n\\-u Updates Bash\\-Snippets\n.\n.IP \"\" 0\n.\n.SS \"Gist\"\nDescription: Manage your gists with git and Github API v3\n.\n.P\nUsage: gist [command] [args]\n.\n.IP \"\\(bu\" 4\n[star|all] List your gists, use \\'star\\' as argument for your starred gists, \\'all\\' or \\'a\\' for both your and starred gists\\. Format for each line is: \\fIINDEX\\fR \\fIURL\\fR \\fIFILE_NUM\\fR \\fICOMMENT_NUM\\fR \\fIDESCRIPTION\\fR\n.\n.IP \"\\(bu\" 4\nfetch Update the local list of your gists, \\'star\\' as argument for your starred gists\n.\n.IP \"\\(bu\" 4\n\\fIINDEX\\fR Show the path of local gist repo and do custom actions\n.\n.IP \"\\(bu\" 4\nnew Create a new gist with files or STDIN\n.\n.IP \"\\(bu\" 4\ngrep Grep gists by description, filename and content with a given pattern\n.\n.IP \"\\(bu\" 4\ntag Modify/List tags for a gist\n.\n.IP \"\\(bu\" 4\ntags List all tags and pinned tags\n.\n.IP \"\\(bu\" 4\npin, Pin/Unpin tags, or filter gists with pinned tags\n.\n.IP \"\\(bu\" 4\nlan Filter gists or list gist with coding languages\n.\n.IP \"\\(bu\" 4\ndetail Show the detail of a gist\n.\n.IP \"\\(bu\" 4\nedit Edit description for a gist\n.\n.IP \"\\(bu\" 4\ndelete Delete gists by given indices\n.\n.IP \"\\(bu\" 4\npush Push changes by git\n.\n.IP \"\\(bu\" 4\nclean Clean local repos of removed gists\n.\n.IP \"\\(bu\" 4\nconfig Do configuration\n.\n.IP \"\\(bu\" 4\nuser Get list of gists with a given Github user\n.\n.IP \"\\(bu\" 4\ngithub Import selected gist as a new Github repo\n.\n.IP \"\\(bu\" 4\nhelp Show the helper message\n.\n.IP \"\" 0\n.\n.P\nExample:\n.\n.IP \"\\(bu\" 4\ngist (Show your gists)\n.\n.IP \"\\(bu\" 4\ngist tag (Show your gists with tags)\n.\n.IP \"\\(bu\" 4\ngist fetch (update the list of gists from github\\.com)\n.\n.IP \"\\(bu\" 4\ngist 3 (show the repo path of your 3rd gist, and do custom actions)\n.\n.IP \"\\(bu\" 4\ngist 3 \\-\\-no\\-action (show the repo path of your 3rd gist, and do not perform actions)\n.\n.IP \"\\(bu\" 4\ngist new \\-\\-desc bar foo (create a new gist with files and description)\n.\n.IP \"\" 0\n.\n.SS \"Lyrics\"\nDescription: Fetch lyrics for a certain song\\.\n.\n.P\nUsage: lyrics [flags] or tool [\\-a] [arg] [\\-s] [arg]\n.\n.IP \"\\(bu\" 4\n\\-a Artist of the song to fetch lyrics for\n.\n.IP \"\\(bu\" 4\n\\-s Song of the artist to fetch lyrics for\n.\n.IP \"\\(bu\" 4\n\\-f Export the lyrics to file rather than outputting to stdout\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\nlyrics \\-a logic \\-s run it\n.\n.IP \"\\(bu\" 4\nlyrics \\-a logic \\-s run it \\-f ~/runItLyrics\\.txt\n.\n.IP \"\" 0\n.\n.SS \"Meme\"\nDescription: A lightning fast meme generator\n.\n.P\nUsage: tool [flags] or tool [flags] [arguments]\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-f Choose the output filename\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\nmeme \\-f dogeMeme\n.\n.IP \"\" 0\n.\n.SS \"Movies\"\nDescription: Provides relevant information about a certain movie\\.\n.\n.P\nUsage: movies [flag] or movies [movieToSearch]\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\\(bu\" 4\n\\-d Show detailed information\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\nmovies Argo\n.\n.IP \"\\(bu\" 4\nmovies Inception\n.\n.IP \"\" 0\n.\n.SS \"Newton\"\nDescription: Performs numerical calculations all the way up to symbolic math parsing\\.\n.\n.P\nUsage: newton [operation] [expression] or newton [flag]\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nValid Symbols: + add \\- subtract [ left parenthesis (you must use brackets bash has a bultin for parenthesis) ] right parenthesis (you must use brackets bash has a bultin for parenthesis) * multiply / divide ^ power : between the range of left and right side (only for area under curve) ~ parameter on right side (only for area, tangent line and log)\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\nnewton simplify [[2x]+7]*[4x]\n.\n.IP \"\\(bu\" 4\nmovies derive x+2x\n.\n.IP \"\" 0\n.\n.SS \"Pwned\"\nUsage: pwned [email]\n.\n.P\nDescription: Checks where an email account has been breached\n.\n.IP \"\" 4\n.\n.nf\n\n* \\-u Update Bash\\-Snippet Tools\n\n* \\-h Show the help\n\n* \\-v Get the tool version\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\" 4\n.\n.nf\n\n* pwned emailtocheck@email\\.com\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Qrify\"\nUsage: qrify [stringtoturnintoqrcode]\n.\n.P\nDescription: Converts strings or urls into a qr code\\.\n.\n.IP \"\" 4\n.\n.nf\n\n* \\-u Update Bash\\-Snippet Tools\n\n* \\-m Enable multiline support\n\n* \\-f Save the QRCode to a file\n\n* \\-d Decode the QR code from a PNG/GIF/JP(E)G file\n\n* \\-h Show the help\n\n* \\-v Get the tool version\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\" 4\n.\n.nf\n\n* qrify this is a test string\n\n* qrify \\-m two \\en lines\n\n* qrify \\-f fileNameHere Insert what you want to encode here\n\n* qrify github\\.com # notice no http:// or https:// this will fail\n\n* qrify \\-d fileName\\.png\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Short\"\nDescription: Unmasks shortended urls\\.\n.\n.P\nUsage: short [shortURL] or short [flag]\n.\n.IP \"\\(bu\" 4\n\\-e Expand the following URL\n.\n.IP \"\\(bu\" 4\n\\-s Shorten the following URL\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExample:\n.\n.IP \"\\(bu\" 4\nInput: short \\-e tinyurl\\.com/jhkj\n.\n.IP \"\\(bu\" 4\nOutput: http://possiblemaliciouswebsiteornot\\.com\n.\n.IP \"\\(bu\" 4\nInput: short \\-s google\\.com\n.\n.IP \"\\(bu\" 4\nOutput: http://ki\\.tc/23sd1d\n.\n.IP \"\" 0\n.\n.SS \"Siteciphers\"\nDescription: Checks the available ciphers for the SSL of an https site\\.\n.\n.P\nUsage: siteciphers [flag] or siteciphers [optionalDFlag] [website]\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\\(bu\" 4\n\\-d Set the delay between requests sent to the site (default is 1 sec)\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\nsiteciphers github\\.com\n.\n.IP \"\\(bu\" 4\nsiteciphers \\-d 0\\.75 google\\.com\n.\n.IP \"\" 0\n.\n.SS \"Stocks\"\nDescription: Finds the latest information on a certain stock\\.\n.\n.P\nUsage: stocks [flag] or stocks [company/ticker]\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\nstocks AAPL\n.\n.IP \"\\(bu\" 4\nstocks Tesla\n.\n.IP \"\" 0\n.\n.SS \"Taste\"\nDescription: A recommendation engine that provides 3 similar items based on some input topic\\. Taste also has the ability to provide information on the item of interest\\. Supports: shows, books, music, artists, movies, authors, games\n.\n.P\nUsage: taste [flag] [item]\n.\n.IP \"\\(bu\" 4\n\\-i Get more information on similar items\n.\n.IP \"\\(bu\" 4\n\\-s Get information on the item itself\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\ntaste \\-i Kendrick Lamar\n.\n.IP \"\\(bu\" 4\ntaste Catcher in the Ry\n.\n.IP \"\\(bu\" 4\ntaste \\-s Red Hot Chili Peppers\n.\n.IP \"\" 0\n.\n.SS \"Todo\"\nDescription: A simplistic commandline todo list\\.\n.\n.P\nUsage: todo [flags] or todo [flags] [arguments]\n.\n.IP \"\\(bu\" 4\n\\-c Clear all the current tasks\n.\n.IP \"\\(bu\" 4\n\\-r Remove the following task number\n.\n.IP \"\\(bu\" 4\n\\-g Get the current tasks\n.\n.IP \"\\(bu\" 4\n\\-a Add the following task\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\ntodo \\-a My very first task\n.\n.IP \"\\(bu\" 4\ntodo \\-r 1\n.\n.IP \"\\(bu\" 4\ntodo \\-g\n.\n.IP \"\\(bu\" 4\ntodo \\-c\n.\n.IP \"\" 0\n.\n.SS \"Transfer\"\nDescription: Quickly transfer files from the command line\\.\n.\n.P\nUsage: transfer [flags] or transfer [flag] [args] or transfer [filePathToUpload]\n.\n.IP \"\\(bu\" 4\n\\-d Download a single file\n.\n.IP \"\" 4\n.\n.nf\n\n* First arg: Output file directory\n* Second arg: File url id\n* Third arg: File name\n.\n.fi\n.\n.IP \"\" 0\n\n.\n.IP \"\\(bu\" 4\n\\-o Onetime file upload\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\ntransfer ~/fileToTransfer\\.txt\n.\n.IP \"\\(bu\" 4\ntransfer ~/firstFileToTransfer\\.txt ~/secondFileToTransfer\\.txt # upload multiple files at once\n.\n.IP \"\\(bu\" 4\ntransfer \\-d ~/outputDirectory fileID fileName\n.\n.IP \"\\(bu\" 4\ntransfer \\-o ~/fileToTransfer\\.txt\n.\n.IP \"\" 0\n.\n.SS \"Weather\"\nDescription: Provides a 3 day forecast on your current location or a specified location\\. With no flags Weather will default to your current location\\.\n.\n.P\nUsage: weather or weather [flag] or weather [country] or weather [city] [state]\n.\n.IP \"\\(bu\" 4\nweather [optionalLocation] [i][M] get weather in imperial units, optional M means windspeed in m/s\n.\n.IP \"\\(bu\" 4\nweather [optionalLocation] [m][M] lowercase m gets weather in metric units, optional M means windspeed in m/s\n.\n.IP \"\\(bu\" 4\nweather [Moon] grabs the phase of the moon\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\nweather\n.\n.IP \"\\(bu\" 4\nweather Paris m\n.\n.IP \"\\(bu\" 4\nweather Tokyo\n.\n.IP \"\\(bu\" 4\nweather Moon\n.\n.IP \"\\(bu\" 4\nweather mM\n.\n.IP \"\" 0\n.\n.SS \"Ytview\"\nDescription: Search and play youtube videos right from the terminal\\.\n.\n.P\nUsage: ytview [flag] [string] or ytview [videoToSearch]\n.\n.IP \"\\(bu\" 4\n\\-s Searches youtube\n.\n.IP \"\\(bu\" 4\n\\-c Shows the latest videos of a channel\n.\n.IP \"\\(bu\" 4\n\\-u Update Bash\\-Snippet Tools\n.\n.IP \"\\(bu\" 4\n\\-h Show the help\n.\n.IP \"\\(bu\" 4\n\\-v Get the tool version\n.\n.IP \"\" 0\n.\n.P\nExamples:\n.\n.IP \"\\(bu\" 4\nytview \\-s Family Guy Chicken Fight\n.\n.IP \"\\(bu\" 4\nytview \\-c Numberphile\n.\n.IP \"\" 0\n.\n.SH \"Updating\"\nWith any of the installed tools you can automate the update by running it with the \\-u option or passing in update as the arguments\n.\n.IP \"\\(bu\" 4\nstocks update\n.\n.IP \"\" 0\n.\n.P\nor\n.\n.IP \"\\(bu\" 4\nstocks \\-u\n.\n.IP \"\" 0\n.\n.P\nThis will clone the repository and install the new versions of scripts that were installed, if you didn\\'t install a certain tool this script will not install the new version of that tool\\.\n.\n.SH \"Uninstalling\"\nIf you don\\'t have the Bash\\-Snippets folder anymore clone the repository: git clone https://github\\.com/alexanderepstein/Bash\\-Snippets`\n.\n.P\ncd into the Bash\\-Snippets directory: \\fBcd Bash\\-Snippets\\fR\n.\n.IP \"\" 4\n.\n.nf\n\nTo go through a guided uninstall\n.\n.fi\n.\n.IP \"\" 0\n.\n.IP \"\\(bu\" 4\n\\&\\./uninstall\\.sh\n.\n.IP \"\" 0\n.\n.SH \"AUTHOR\"\nAlexander Epstein Github: https://github\\.com/alexanderepstein\n.\n.SH \"Contributors\"\nJake Meyer Github: https://github\\.com/jakewmeyer\n.\n.P\nLinyos Torovoltos Github: https://gitbub\\.com/linyostorovovoltos\n.\n.SH \"License\"\nMIT License\n.\n.P\nCopyright (c) 2017 Alex Epstein\n.\n.P\nPermission 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:\n.\n.P\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software\\.\n.\n.P\nTHE 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\\.\n"
  },
  {
    "path": "bash-snippets.1.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <meta http-equiv='content-type' value='text/html;charset=utf8'>\n  <meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>\n  <title>bash-snippets(1) - A collection of small bash scripts for heavy terminal users</title>\n  <style type='text/css' media='all'>\n  /* style: man */\n  body#manpage {margin:0}\n  .mp {max-width:100ex;padding:0 9ex 1ex 4ex}\n  .mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}\n  .mp h2 {margin:10px 0 0 0}\n  .mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}\n  .mp h3 {margin:0 0 0 4ex}\n  .mp dt {margin:0;clear:left}\n  .mp dt.flush {float:left;width:8ex}\n  .mp dd {margin:0 0 0 9ex}\n  .mp h1,.mp h2,.mp h3,.mp h4 {clear:left}\n  .mp pre {margin-bottom:20px}\n  .mp pre+h2,.mp pre+h3 {margin-top:22px}\n  .mp h2+pre,.mp h3+pre {margin-top:5px}\n  .mp img {display:block;margin:auto}\n  .mp h1.man-title {display:none}\n  .mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}\n  .mp h2 {font-size:16px;line-height:1.25}\n  .mp h1 {font-size:20px;line-height:2}\n  .mp {text-align:justify;background:#fff}\n  .mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}\n  .mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}\n  .mp u {text-decoration:underline}\n  .mp code,.mp strong,.mp b {font-weight:bold;color:#131211}\n  .mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}\n  .mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}\n  .mp b.man-ref {font-weight:normal;color:#434241}\n  .mp pre {padding:0 4ex}\n  .mp pre code {font-weight:normal;color:#434241}\n  .mp h2+pre,h3+pre {padding-left:0}\n  ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}\n  ol.man-decor {width:100%}\n  ol.man-decor li.tl {text-align:left}\n  ol.man-decor li.tc {text-align:center;letter-spacing:4px}\n  ol.man-decor li.tr {text-align:right;float:right}\n  </style>\n</head>\n<!--\n  The following styles are deprecated and will be removed at some point:\n  div#man, div#man ol.man, div#man ol.head, div#man ol.man.\n\n  The .man-page, .man-decor, .man-head, .man-foot, .man-title, and\n  .man-navigation should be used instead.\n-->\n<body id='manpage'>\n  <div class='mp' id='man'>\n\n  <div class='man-navigation' style='display:none'>\n    <a href=\"#NAME\">NAME</a>\n    <a href=\"#Tools\">Tools</a>\n    <a href=\"#Updating\">Updating</a>\n    <a href=\"#Uninstalling\">Uninstalling</a>\n    <a href=\"#AUTHOR\">AUTHOR</a>\n    <a href=\"#Contributors\">Contributors</a>\n    <a href=\"#License\">License</a>\n  </div>\n\n  <ol class='man-decor man-head man head'>\n    <li class='tl'>bash-snippets(1)</li>\n    <li class='tc'></li>\n    <li class='tr'>bash-snippets(1)</li>\n  </ol>\n\n  <h2 id=\"NAME\">NAME</h2>\n<p class=\"man-name\">\n  <code>bash-snippets</code> - <span class=\"man-whatis\">A collection of small bash scripts for heavy terminal users</span>\n</p>\n\n<h2 id=\"Tools\">Tools</h2>\n\n<h3 id=\"Cheat\">Cheat</h3>\n\n<p>Description: Cheatsheets for quick information about multiple programming languages along with terminal commands</p>\n\n<p>Usage: cheat [flags] [command] or cheat [flags] [programming language] [subject]</p>\n\n<ul>\n<li><p>-s Does a search for last argument rather than looking for exact match</p></li>\n<li><p>-i Case insensitive search</p></li>\n<li><p>-b Word boundaries in search</p></li>\n<li><p>-r Recursive search</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Special Pages:</p>\n\n<ul>\n<li><p>hello Describes building the hello world program written in the language</p></li>\n<li><p>list This lists all cheatsheets related to previous arg if none it lists all cheatsheets</p></li>\n<li><p>learn Shows a learn-x-in-minutes language cheat sheet perfect for getting started with the language</p></li>\n<li><p>1line A collection of one-liners in this language</p></li>\n<li><p>weirdness A collection of examples of weird things in this language</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>cheat rust hello</p></li>\n<li><p>cheat -r -b -i go</p></li>\n<li><p>cheat julia Functions</p></li>\n<li><p>cheat -i go operators</p></li>\n</ul>\n\n\n<h3 id=\"Cloudup\">Cloudup</h3>\n\n<p>Description: Backs up a users github repositories to your bitbucket account.\n  With no flags cloudup will guide you through backing up a single repository</p>\n\n<p>Usage: cloudup [flags] or cloudup [flags] [listOfGHRepoNamesSplitBySpaces]</p>\n\n<ul>\n<li><p>-p Upload the repositor(y)(ies) as private to bitbucket (must have private repo ability on bitbucket)</p></li>\n<li><p>-a Backup all github repositories</p></li>\n<li><p>-s Only backup repositories that you have created (no forks) (only works in conjunction with the -a flag)</p></li>\n<li><p>-t Backup the repository with a timestamp added to the repostiory name (will always create a new unique bitbucket repo)</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p> cloudup</p></li>\n<li><p> cloudup -p -a</p></li>\n<li><p> cloudup -p nameOfRepo1 nameOf Repo2</p></li>\n<li><p> cloudup nameOfRep</p></li>\n</ul>\n\n\n<h3 id=\"Crypt\">Crypt</h3>\n\n<p>Description: A wrapper around openssl that facilitates encrypting and decrypting files.</p>\n\n<p>Usage: crypt [flag] [inputFile] [outputFile]</p>\n\n<ul>\n<li><p>-e Encrypt the inputFile and store it in the outputFil</p></li>\n<li><p>-d Decrypt the inputFile and store it in the outputFil</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>crypt -e mySecretFile.txt myEncryptedFile.jpg (change filetype so default program is incorrect)</p></li>\n<li><p>crypt -d myEncryptedFile.jpg thisIsNowDecrypted.txt (change filetype back so now default program is correct)</p></li>\n</ul>\n\n\n<h3 id=\"CryptoCurrency\">CryptoCurrency</h3>\n\n<p>Description: A realtime cryptocurrency converter.\nWith no flags it will pull down the latest stats of the top 10 cryptos</p>\n\n<p>Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [flag] [arg]</p>\n\n<ul>\n<li><p>-o Utilize the old functionality of the tool</p></li>\n<li><p>-f Fiat currency for conversions</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:\n  cryptocurrency -o\n  cryptocurrency -f eur</p>\n\n<h3 id=\"Currency\">Currency</h3>\n\n<p>Description: A realtime currency converter.\n   With no flags it will guide you through the currency exchange</p>\n\n<p>Usage: currency or currency [flag] or currency [base] [exchangeTo] [amount]</p>\n\n<ul>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Supported Currencies:</p>\n\n<hr />\n\n<p>| AUD | BGN | BRL | CAD |\n| CHF | CNY | CZK | DKK |\n| EUR | GBP | HKD | HRK |\n| HUF | IDR | ILS | INR |\n| JPY | KRW | MXN | MYR |\n| NOK | NZD | PHP | PLN |\n| RON | RUB | SEK | SGD |\n| THB | TRY | USD | ZAR |</p>\n\n<hr />\n\n<p>Examples:</p>\n\n<ul>\n<li><p>currency EUR USD 12.35</p></li>\n<li><p>currency</p></li>\n</ul>\n\n\n<h3 id=\"Geo\">Geo</h3>\n\n<p>Description: Provides quick access for wan, lan, router, dns, mac, and ip geolocation data</p>\n\n<p>Usage: geo [flag]</p>\n\n<ul>\n<li><p>-w  Returns WAN IP</p></li>\n<li><p>-l  Returns LAN IP(s)</p></li>\n<li><p>-r  Returns Router IP</p></li>\n<li><p>-d  Returns DNS Nameserver</p></li>\n<li><p>-m  Returns MAC address for interface. Ex. eth0</p></li>\n<li><p>-g  Returns Current IP Geodata</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>geo -g</p></li>\n<li><p>geo -wlrdgm eth0</p></li>\n</ul>\n\n\n<p>Custom Geo Output =>\n[all] [query] [city] [region] [country] [zip] [isp]</p>\n\n<p>Example: geo -a 8.8.8.8 -o city,zip,isp</p>\n\n<ul>\n<li><p>-o  [options] Returns Specific Geodata</p></li>\n<li><p>-a  [address] For specific ip in -s</p></li>\n<li><p>-v  Returns Version</p></li>\n<li><p>-h  Returns Help Screen</p></li>\n<li><p>-u  Updates Bash-Snippets</p></li>\n</ul>\n\n\n<h3 id=\"Gist\">Gist</h3>\n\n<p>Description: Manage your gists with git and Github API v3</p>\n\n<p>Usage: gist [command] [args]</p>\n\n<ul>\n<li><p>[star|all]  List your gists, use 'star' as argument for your starred gists,\n            'all' or 'a' for both your and starred gists. Format for each line is:\n            <var>INDEX</var> <var>URL</var> <var>FILE_NUM</var> <var>COMMENT_NUM</var> <var>DESCRIPTION</var></p></li>\n<li><p>fetch       Update the local list of your gists, 'star' as argument for your starred gists</p></li>\n<li><p><var>INDEX</var>     Show the path of local gist repo and do custom actions</p></li>\n<li><p>new         Create a new gist with files or STDIN</p></li>\n<li><p>grep        Grep gists by description, filename and content with a given pattern</p></li>\n<li><p>tag         Modify/List tags for a gist</p></li>\n<li><p>tags        List all tags and pinned tags</p></li>\n<li><p>pin,        Pin/Unpin tags, or filter gists with pinned tags</p></li>\n<li><p>lan         Filter gists or list gist with coding languages</p></li>\n<li><p>detail      Show the detail of a gist</p></li>\n<li><p>edit        Edit description for a gist</p></li>\n<li><p>delete      Delete gists by given indices</p></li>\n<li><p>push        Push changes by git</p></li>\n<li><p>clean       Clean local repos of removed gists</p></li>\n<li><p>config      Do configuration</p></li>\n<li><p>user        Get list of gists with a given Github user</p></li>\n<li><p>github      Import selected gist as a new Github repo</p></li>\n<li><p>help        Show the helper message</p></li>\n</ul>\n\n\n<p>Example:</p>\n\n<ul>\n<li><p>gist                    (Show your gists)</p></li>\n<li><p>gist tag                (Show your gists with tags)</p></li>\n<li><p>gist fetch              (update the list of gists from github.com)</p></li>\n<li><p>gist 3                  (show the repo path of your 3rd gist, and do custom actions)</p></li>\n<li><p>gist 3 --no-action      (show the repo path of your 3rd gist, and do not perform actions)</p></li>\n<li><p>gist new --desc bar foo (create a new gist with files and description)</p></li>\n</ul>\n\n\n<h3 id=\"Lyrics\">Lyrics</h3>\n\n<p>Description: Fetch lyrics for a certain song.</p>\n\n<p>Usage: lyrics [flags] or tool [-a] [arg] [-s] [arg]</p>\n\n<ul>\n<li><p>-a  Artist of the song to fetch lyrics for</p></li>\n<li><p>-s  Song of the artist to fetch lyrics for</p></li>\n<li><p>-f  Export the lyrics to file rather than outputting to stdout</p></li>\n<li><p>-u  Update Bash-Snippet Tools</p></li>\n<li><p>-h  Show the help</p></li>\n<li><p>-v  Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>lyrics -a logic -s run it</p></li>\n<li><p>lyrics -a logic -s run it -f ~/runItLyrics.txt</p></li>\n</ul>\n\n\n<h3 id=\"Meme\">Meme</h3>\n\n<p>Description: A lightning fast meme generator</p>\n\n<p>Usage: tool [flags] or tool [flags] [arguments]</p>\n\n<ul>\n<li><p>-u  Update Bash-Snippet Tools</p></li>\n<li><p>-h  Show the help</p></li>\n<li><p>-f  Choose the output filename</p></li>\n<li><p>-v  Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li>meme -f dogeMeme</li>\n</ul>\n\n\n<h3 id=\"Movies\">Movies</h3>\n\n<p>Description: Provides relevant information about a certain movie.</p>\n\n<p>Usage: movies [flag] or movies [movieToSearch]</p>\n\n<ul>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n<li><p>-d Show detailed information</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>movies Argo</p></li>\n<li><p>movies Inception</p></li>\n</ul>\n\n\n<h3 id=\"Newton\">Newton</h3>\n\n<p>Description: Performs numerical calculations all the way up to symbolic math parsing.</p>\n\n<p>Usage: newton [operation] [expression] or newton [flag]</p>\n\n<ul>\n<li><p>-u  Update Bash-Snippet Tools</p></li>\n<li><p>-h  Show the help</p></li>\n<li><p>-v  Get the tool version</p></li>\n</ul>\n\n\n<table>\n<thead>\n<tr>\n<th>Operations     Sample Expression      Sample Result</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Simplify       [[2x<sup>2</sup>]+7]*[4x<sup>2</sup>]    8 x<sup>4</sup> + 28 x<sup>2</sup> </td>\n</tr>\n<tr>\n<td>Factor             x<sup>2</sup> + 2x             x (x + 2)  </td>\n</tr>\n<tr>\n<td>Derive              x<sup>2</sup>+2x               2 x + 2   </td>\n</tr>\n<tr>\n<td>Integrate           x<sup>2</sup>+2x         1/3 x<sup>3</sup> + x<sup>2</sup> +C</td>\n</tr>\n<tr>\n<td>Roots/Zeroes        x<sup>2</sup>+2x                2, 0     </td>\n</tr>\n<tr>\n<td>Tangent             2~x<sup>3</sup>              12 x + -16  | (Finding tangent line when x=2 for expression x<sup>3</sup>)</td>\n</tr>\n<tr>\n<td>Area               2:4~x<sup>3</sup>                 60      | (Finding area under curve from 2 to 4 for expression x<sup>3</sup>)</td>\n</tr>\n<tr>\n<td>Cos                   pi                   -1      </td>\n</tr>\n<tr>\n<td>Sin                   pi                    0      </td>\n</tr>\n<tr>\n<td>Tan                  pi/4                   1      </td>\n</tr>\n<tr>\n<td>ArcCos                 1                    0      </td>\n</tr>\n<tr>\n<td>ArcSin                 0                    0      </td>\n</tr>\n<tr>\n<td>ArcTan                pi                arcsin(pi) </td>\n</tr>\n<tr>\n<td>Abs                   -2                    2      </td>\n</tr>\n<tr>\n<td>Log                   2~8                   3      | (Log base 2 of eight)</td>\n</tr>\n</tbody>\n</table>\n\n\n<p>  Valid Symbols:\n    + add\n    - subtract\n    [ left parenthesis (you must use brackets bash has a bultin for parenthesis)\n    ] right parenthesis (you must use brackets bash has a bultin for parenthesis)\n    * multiply\n    / divide\n    ^ power\n    : between the range of left and right side (only for area under curve)\n    ~ parameter on right side (only for area, tangent line and log)</p>\n\n<p>Examples:</p>\n\n<ul>\n<li><p>newton simplify [[2x<sup>2</sup>]+7]*[4x<sup>2</sup>]</p></li>\n<li><p>movies derive x<sup>2</sup>+2x</p></li>\n</ul>\n\n\n<h3 id=\"Pwned\">Pwned</h3>\n\n<p>Usage: pwned [email]</p>\n\n<p>Description: Checks where an email account has been breached</p>\n\n<pre><code>* -u Update Bash-Snippet Tools\n\n* -h Show the help\n\n* -v Get the tool version\n</code></pre>\n\n<p>Examples:</p>\n\n<pre><code>* pwned emailtocheck@email.com\n</code></pre>\n\n<h3 id=\"Qrify\">Qrify</h3>\n\n<p>Usage: qrify [stringtoturnintoqrcode]</p>\n\n<p>Description: Converts strings or urls into a qr code.</p>\n\n<pre><code>* -u Update Bash-Snippet Tools\n\n* -m Enable multiline support\n\n* -f Save the QRCode to a file\n\n* -d Decode the QR code from a PNG/GIF/JP(E)G file\n\n* -h Show the help\n\n* -v Get the tool version\n</code></pre>\n\n<p>Examples:</p>\n\n<pre><code>* qrify this is a test string\n\n* qrify -m two \\n lines\n\n* qrify -f fileNameHere Insert what you want to encode here\n\n* qrify github.com # notice no http:// or https:// this will fail\n\n* qrify -d fileName.png\n</code></pre>\n\n<h3 id=\"Short\">Short</h3>\n\n<p>Description: Unmasks shortended urls.</p>\n\n<p>Usage: short [shortURL] or short [flag]</p>\n\n<ul>\n<li><p>-e Expand the following URL</p></li>\n<li><p>-s Shorten the following URL</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Example:</p>\n\n<ul>\n<li><p> Input: short -e tinyurl.com/jhkj</p></li>\n<li><p> Output: http://possiblemaliciouswebsiteornot.com</p></li>\n<li><p> Input: short -s google.com</p></li>\n<li><p> Output: http://ki.tc/23sd1d</p></li>\n</ul>\n\n\n<h3 id=\"Siteciphers\">Siteciphers</h3>\n\n<p>Description: Checks the available ciphers for the SSL of an https site.</p>\n\n<p>Usage: siteciphers [flag] or siteciphers [optionalDFlag] [website]</p>\n\n<ul>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n<li><p>-d Set the delay between requests sent to the site (default is 1 sec)</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>siteciphers github.com</p></li>\n<li><p>siteciphers -d 0.75 google.com</p></li>\n</ul>\n\n\n<h3 id=\"Stocks\">Stocks</h3>\n\n<p>Description: Finds the latest information on a certain stock.</p>\n\n<p>Usage: stocks [flag] or stocks [company/ticker]</p>\n\n<ul>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>stocks AAPL</p></li>\n<li><p>stocks Tesla</p></li>\n</ul>\n\n\n<h3 id=\"Taste\">Taste</h3>\n\n<p>Description: A recommendation engine that provides 3 similar items based on some input topic.\n  Taste also has the ability to provide information on the item of interest.\n  Supports: shows, books, music, artists, movies, authors, games</p>\n\n<p>Usage: taste [flag] [item]</p>\n\n<ul>\n<li><p>-i Get more information on similar items</p></li>\n<li><p>-s Get information on the item itself</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>taste -i Kendrick Lamar</p></li>\n<li><p>taste Catcher in the Ry</p></li>\n<li><p>taste -s Red Hot Chili Peppers</p></li>\n</ul>\n\n\n<h3 id=\"Todo\">Todo</h3>\n\n<p>Description: A simplistic commandline todo list.</p>\n\n<p>Usage: todo [flags] or todo [flags] [arguments]</p>\n\n<ul>\n<li><p>-c Clear all the current tasks</p></li>\n<li><p>-r Remove the following task number</p></li>\n<li><p>-g Get the current tasks</p></li>\n<li><p>-a Add the following task</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>todo -a My very first task</p></li>\n<li><p>todo -r 1</p></li>\n<li><p>todo -g</p></li>\n<li><p>todo -c</p></li>\n</ul>\n\n\n<h3 id=\"Transfer\">Transfer</h3>\n\n<p>Description: Quickly transfer files from the command line.</p>\n\n<p>Usage: transfer [flags] or transfer [flag] [args] or transfer [filePathToUpload]</p>\n\n<ul>\n<li><p>-d  Download a single file</p>\n\n<pre><code>* First arg: Output file directory\n* Second arg: File url id\n* Third arg: File name\n</code></pre></li>\n<li><p>-o  Onetime file upload</p></li>\n<li><p>-u  Update Bash-Snippet Tools</p></li>\n<li><p>-h  Show the help</p></li>\n<li><p>-v  Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>transfer ~/fileToTransfer.txt</p></li>\n<li><p>transfer ~/firstFileToTransfer.txt ~/secondFileToTransfer.txt # upload multiple files at once</p></li>\n<li><p>transfer -d ~/outputDirectory fileID fileName</p></li>\n<li><p>transfer -o ~/fileToTransfer.txt</p></li>\n</ul>\n\n\n<h3 id=\"Weather\">Weather</h3>\n\n<p>Description: Provides a 3 day forecast on your current location or a specified location.\n  With no flags Weather will default to your current location.</p>\n\n<p>Usage: weather or weather [flag] or weather [country] or weather [city] [state]</p>\n\n<ul>\n<li><p>weather [optionalLocation] [i][M] get weather in imperial units, optional M means windspeed in m/s</p></li>\n<li><p>weather [optionalLocation] [m][M] lowercase m gets weather in metric units, optional M means windspeed in m/s</p></li>\n<li><p>weather [Moon] grabs the phase of the moon</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>weather</p></li>\n<li><p>weather Paris m</p></li>\n<li><p>weather Tokyo</p></li>\n<li><p>weather Moon</p></li>\n<li><p>weather mM</p></li>\n</ul>\n\n\n<h3 id=\"Ytview\">Ytview</h3>\n\n<p>Description: Search and play youtube videos right from the terminal.</p>\n\n<p>Usage: ytview [flag] [string] or ytview [videoToSearch]</p>\n\n<ul>\n<li><p>-s Searches youtube</p></li>\n<li><p>-c Shows the latest videos of a channel</p></li>\n<li><p>-u Update Bash-Snippet Tools</p></li>\n<li><p>-h Show the help</p></li>\n<li><p>-v Get the tool version</p></li>\n</ul>\n\n\n<p>Examples:</p>\n\n<ul>\n<li><p>ytview -s Family Guy Chicken Fight</p></li>\n<li><p>ytview -c Numberphile</p></li>\n</ul>\n\n\n<h2 id=\"Updating\">Updating</h2>\n\n<p>  With any of the installed tools you can automate the update by running it with the -u option or passing in update as the arguments</p>\n\n<ul>\n<li>stocks update</li>\n</ul>\n\n\n<p>  or</p>\n\n<ul>\n<li>stocks -u</li>\n</ul>\n\n\n<p>  This will clone the repository and install the new versions of scripts that were installed, if you didn't install a certain tool this script will not install the new version of that tool.</p>\n\n<h2 id=\"Uninstalling\">Uninstalling</h2>\n\n<p>  If you don't have the Bash-Snippets folder anymore clone the repository:  git clone https://github.com/alexanderepstein/Bash-Snippets`</p>\n\n<p>  cd into the Bash-Snippets directory: <code>cd Bash-Snippets</code></p>\n\n<pre><code>To go through a guided uninstall\n</code></pre>\n\n<ul>\n<li> ./uninstall.sh</li>\n</ul>\n\n\n<h2 id=\"AUTHOR\">AUTHOR</h2>\n\n<p>Alexander Epstein\nGithub: https://github.com/alexanderepstein</p>\n\n<h2 id=\"Contributors\">Contributors</h2>\n\n<p>Jake Meyer\nGithub: https://github.com/jakewmeyer</p>\n\n<p>Linyos Torovoltos\nGithub: https://gitbub.com/linyostorovovoltos</p>\n\n<h2 id=\"License\">License</h2>\n\n<p>MIT License</p>\n\n<p>Copyright (c) 2017 Alex Epstein</p>\n\n<p>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:</p>\n\n<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>\n\n<p>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.</p>\n\n\n  <ol class='man-decor man-foot man foot'>\n    <li class='tl'></li>\n    <li class='tc'>April 2020</li>\n    <li class='tr'>bash-snippets(1)</li>\n  </ol>\n\n  </div>\n</body>\n</html>\n"
  },
  {
    "path": "bash-snippets.1.ronn",
    "content": "bash-snippets(1) -- A collection of small bash scripts for heavy terminal users\n====\n\n## Tools\n\n### Cheat\nDescription: Cheatsheets for quick information about multiple programming languages along with terminal commands\n\nUsage: cheat [flags] [command] or cheat [flags] [programming language] [subject]\n\n  * -s Does a search for last argument rather than looking for exact match\n\n  * -i Case insensitive search\n\n  * -b Word boundaries in search\n\n  * -r Recursive search\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nSpecial Pages:\n\n  * hello Describes building the hello world program written in the language\n\n  * list This lists all cheatsheets related to previous arg if none it lists all cheatsheets\n\n  * learn Shows a learn-x-in-minutes language cheat sheet perfect for getting started with the language\n\n  * 1line A collection of one-liners in this language\n\n  * weirdness A collection of examples of weird things in this language\n\nExamples:\n\n  * cheat rust hello\n\n  * cheat -r -b -i go\n\n  * cheat julia Functions\n\n  * cheat -i go operators\n\n### Cloudup\nDescription: Backs up a users github repositories to your bitbucket account.\n  With no flags cloudup will guide you through backing up a single repository\n\nUsage: cloudup [flags] or cloudup [flags] [listOfGHRepoNamesSplitBySpaces]\n\n  * -p Upload the repositor(y)(ies) as private to bitbucket (must have private repo ability on bitbucket)\n\n  * -a Backup all github repositories\n\n  * -s Only backup repositories that you have created (no forks) (only works in conjunction with the -a flag)\n\n  * -t Backup the repository with a timestamp added to the repostiory name (will always create a new unique bitbucket repo)\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nExamples:\n\n   * cloudup\n\n   * cloudup -p -a\n\n   * cloudup -p nameOfRepo1 nameOf Repo2\n\n   * cloudup nameOfRep\n\n### Crypt\nDescription: A wrapper around openssl that facilitates encrypting and decrypting files.\n\nUsage: crypt [flag] [inputFile] [outputFile]\n\n  * -e Encrypt the inputFile and store it in the outputFil\n\n  * -d Decrypt the inputFile and store it in the outputFil\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nExamples:\n\n  * crypt -e mySecretFile.txt myEncryptedFile.jpg (change filetype so default program is incorrect)\n\n  * crypt -d myEncryptedFile.jpg thisIsNowDecrypted.txt (change filetype back so now default program is correct)\n\n### CryptoCurrency\nDescription: A realtime cryptocurrency converter.\nWith no flags it will pull down the latest stats of the top 10 cryptos\n\nUsage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [flag] [arg]\n\n  * -o Utilize the old functionality of the tool\n\n  * -f Fiat currency for conversions\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\n\n\nExamples:\n  cryptocurrency -o\n  cryptocurrency -f eur\n\n### Currency\nDescription: A realtime currency converter.\n   With no flags it will guide you through the currency exchange\n\nUsage: currency or currency [flag] or currency [base] [exchangeTo] [amount]\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nSupported Currencies:\n _______________________\n| AUD | BGN | BRL | CAD |\n| CHF | CNY | CZK | DKK |\n| EUR | GBP | HKD | HRK |\n| HUF | IDR | ILS | INR |\n| JPY | KRW | MXN | MYR |\n| NOK | NZD | PHP | PLN |\n| RON | RUB | SEK | SGD |\n| THB | TRY | USD | ZAR |\n _______________________\n\nExamples:\n\n  * currency EUR USD 12.35\n\n  * currency\n\n### Geo\nDescription: Provides quick access for wan, lan, router, dns, mac, and ip geolocation data\n\nUsage: geo [flag]\n\n  * -w  Returns WAN IP\n\n  * -l  Returns LAN IP(s)\n\n  * -r  Returns Router IP\n\n  * -d  Returns DNS Nameserver\n\n  * -m  Returns MAC address for interface. Ex. eth0\n\n  * -g  Returns Current IP Geodata\n\nExamples:\n\n  * geo -g\n\n  * geo -wlrdgm eth0\n\nCustom Geo Output =>\n[all] [query] [city] [region] [country] [zip] [isp]\n\nExample: geo -a 8.8.8.8 -o city,zip,isp\n\n  * -o  [options] Returns Specific Geodata\n\n  * -a  [address] For specific ip in -s\n\n  * -v  Returns Version\n\n  * -h  Returns Help Screen\n\n  * -u  Updates Bash-Snippets\n\n### Gist\nDescription: Manage your gists with git and Github API v3\n\nUsage: gist [command] [args]\n\n  * [star|all]  List your gists, use 'star' as argument for your starred gists,\n                'all' or 'a' for both your and starred gists. Format for each line is:\n                <INDEX> <URL> <FILE_NUM> <COMMENT_NUM> <DESCRIPTION>\n\n  * fetch       Update the local list of your gists, 'star' as argument for your starred gists\n   \n  * <INDEX>     Show the path of local gist repo and do custom actions\n\n  * new         Create a new gist with files or STDIN\n\n  * grep        Grep gists by description, filename and content with a given pattern\n\n  * tag         Modify/List tags for a gist\n\n  * tags        List all tags and pinned tags\n\n  * pin,        Pin/Unpin tags, or filter gists with pinned tags\n\n  * lan         Filter gists or list gist with coding languages\n\n  * detail      Show the detail of a gist\n\n  * edit        Edit description for a gist\n\n  * delete      Delete gists by given indices\n\n  * push        Push changes by git\n\n  * clean       Clean local repos of removed gists\n\n  * config      Do configuration\n\n  * user        Get list of gists with a given Github user\n\n  * github      Import selected gist as a new Github repo\n\n  * help        Show the helper message\n\nExample:\n\n  * gist                    (Show your gists)\n\n  * gist tag                (Show your gists with tags)\n\n  * gist fetch              (update the list of gists from github.com)\n\n  * gist 3                  (show the repo path of your 3rd gist, and do custom actions)\n\n  * gist 3 --no-action      (show the repo path of your 3rd gist, and do not perform actions)\n\n  * gist new --desc bar foo (create a new gist with files and description)\n\n### Lyrics\nDescription: Fetch lyrics for a certain song.\n\nUsage: lyrics [flags] or tool [-a] [arg] [-s] [arg]\n\n  * -a  Artist of the song to fetch lyrics for\n\n  * -s  Song of the artist to fetch lyrics for\n\n  * -f  Export the lyrics to file rather than outputting to stdout\n\n  * -u  Update Bash-Snippet Tools\n\n  * -h  Show the help\n\n  * -v  Get the tool version\n\nExamples:\n\n  * lyrics -a logic -s run it\n\n  * lyrics -a logic -s run it -f ~/runItLyrics.txt\n\n### Meme\nDescription: A lightning fast meme generator\n\nUsage: tool [flags] or tool [flags] [arguments]\n\n  * -u  Update Bash-Snippet Tools\n\n  * -h  Show the help\n\n  * -f  Choose the output filename\n\n  * -v  Get the tool version\n\nExamples:\n\n  * meme -f dogeMeme\n\n### Movies\nDescription: Provides relevant information about a certain movie.\n\nUsage: movies [flag] or movies [movieToSearch]\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\n  * -d Show detailed information\n\nExamples:\n\n  * movies Argo\n\n  * movies Inception\n\n### Newton\nDescription: Performs numerical calculations all the way up to symbolic math parsing.\n\nUsage: newton [operation] [expression] or newton [flag]\n\n  * -u  Update Bash-Snippet Tools\n\n  * -h  Show the help\n\n  * -v  Get the tool version\n\n\n|Operations     Sample Expression      Sample Result|\n|---------------------------------------------------|\n|Simplify       [[2x^2]+7]*[4x^2]    8 x^4 + 28 x^2 |\n|Factor             x^2 + 2x             x (x + 2)  |\n|Derive              x^2+2x               2 x + 2   |\n|Integrate           x^2+2x         1/3 x^3 + x^2 +C|\n|Roots/Zeroes        x^2+2x                2, 0     |\n|Tangent             2~x^3              12 x + -16  | (Finding tangent line when x=2 for expression x^3)\n|Area               2:4~x^3                 60      | (Finding area under curve from 2 to 4 for expression x^3)\n|Cos                   pi                   -1      |\n|Sin                   pi                    0      |\n|Tan                  pi/4                   1      |\n|ArcCos                 1                    0      |\n|ArcSin                 0                    0      |\n|ArcTan                pi                arcsin(pi) |\n|Abs                   -2                    2      |\n|Log                   2~8                   3      | (Log base 2 of eight)\n\n\n  Valid Symbols:\n    + add\n    - subtract\n    [ left parenthesis (you must use brackets bash has a bultin for parenthesis)\n    ] right parenthesis (you must use brackets bash has a bultin for parenthesis)\n    * multiply\n    / divide\n    ^ power\n    : between the range of left and right side (only for area under curve)\n    ~ parameter on right side (only for area, tangent line and log)\n\nExamples:\n\n* newton simplify [[2x^2]+7]*[4x^2]\n\n* movies derive x^2+2x\n\n### Pwned\nUsage: pwned [email]\n\nDescription: Checks where an email account has been breached\n\n    * -u Update Bash-Snippet Tools\n\n    * -h Show the help\n\n    * -v Get the tool version\n\nExamples:\n\n    * pwned emailtocheck@email.com\n\n### Qrify\nUsage: qrify [stringtoturnintoqrcode]\n\nDescription: Converts strings or urls into a qr code.\n\n    * -u Update Bash-Snippet Tools\n\n    * -m Enable multiline support\n\n    * -f Save the QRCode to a file\n\n    * -d Decode the QR code from a PNG/GIF/JP(E)G file\n\n    * -h Show the help\n\n    * -v Get the tool version\n\nExamples:\n\n    * qrify this is a test string\n\n    * qrify -m two \\n lines\n\n    * qrify -f fileNameHere Insert what you want to encode here\n\n    * qrify github.com # notice no http:// or https:// this will fail\n\n    * qrify -d fileName.png\n\n### Short\nDescription: Unmasks shortended urls.\n\nUsage: short [shortURL] or short [flag]\n\n  * -e Expand the following URL\n\n  * -s Shorten the following URL\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nExample:\n\n   * Input: short -e tinyurl.com/jhkj\n\n   * Output: http://possiblemaliciouswebsiteornot.com\n\n   * Input: short -s google.com\n\n   * Output: http://ki.tc/23sd1d\n\n### Siteciphers\nDescription: Checks the available ciphers for the SSL of an https site.\n\nUsage: siteciphers [flag] or siteciphers [optionalDFlag] [website]\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\n  * -d Set the delay between requests sent to the site (default is 1 sec)\n\nExamples:\n\n  * siteciphers github.com\n\n  * siteciphers -d 0.75 google.com\n\n### Stocks\nDescription: Finds the latest information on a certain stock.\n\nUsage: stocks [flag] or stocks [company/ticker]\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nExamples:\n\n  * stocks AAPL\n\n  * stocks Tesla\n\n### Taste\nDescription: A recommendation engine that provides 3 similar items based on some input topic.\n  Taste also has the ability to provide information on the item of interest.\n  Supports: shows, books, music, artists, movies, authors, games\n\nUsage: taste [flag] [item]\n\n  * -i Get more information on similar items\n\n  * -s Get information on the item itself\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nExamples:\n\n  * taste -i Kendrick Lamar\n\n  * taste Catcher in the Ry\n\n  * taste -s Red Hot Chili Peppers\n\n### Todo\nDescription: A simplistic commandline todo list.\n\nUsage: todo [flags] or todo [flags] [arguments]\n\n  * -c Clear all the current tasks\n\n  * -r Remove the following task number\n\n  * -g Get the current tasks\n\n  * -a Add the following task\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nExamples:\n\n  * todo -a My very first task\n\n  * todo -r 1\n\n  * todo -g\n\n  * todo -c\n\n### Transfer\nDescription: Quickly transfer files from the command line.\n\nUsage: transfer [flags] or transfer [flag] [args] or transfer [filePathToUpload]\n\n  * -d  Download a single file\n        * First arg: Output file directory\n        * Second arg: File url id\n        * Third arg: File name\n\n  * -o  Onetime file upload\n\n  * -u  Update Bash-Snippet Tools\n\n  * -h  Show the help\n\n  * -v  Get the tool version\n\nExamples:\n\n  * transfer ~/fileToTransfer.txt\n\n  * transfer ~/firstFileToTransfer.txt ~/secondFileToTransfer.txt # upload multiple files at once\n\n  * transfer -d ~/outputDirectory fileID fileName\n\n  * transfer -o ~/fileToTransfer.txt\n\n### Weather\nDescription: Provides a 3 day forecast on your current location or a specified location.\n  With no flags Weather will default to your current location.\n\nUsage: weather or weather [flag] or weather [country] or weather [city] [state]\n\n  * weather [optionalLocation] [i][M] get weather in imperial units, optional M means windspeed in m/s\n\n  * weather [optionalLocation] [m][M] lowercase m gets weather in metric units, optional M means windspeed in m/s\n\n  * weather [Moon] grabs the phase of the moon\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nExamples:\n\n  * weather\n\n  * weather Paris m\n\n  * weather Tokyo\n\n  * weather Moon\n\n  * weather mM\n\n### Ytview\nDescription: Search and play youtube videos right from the terminal.\n\nUsage: ytview [flag] [string] or ytview [videoToSearch]\n\n  * -s Searches youtube\n\n  * -c Shows the latest videos of a channel\n\n  * -u Update Bash-Snippet Tools\n\n  * -h Show the help\n\n  * -v Get the tool version\n\nExamples:\n\n  * ytview -s Family Guy Chicken Fight\n\n  * ytview -c Numberphile\n\n\n## Updating\n\n  With any of the installed tools you can automate the update by running it with the -u option or passing in update as the arguments\n\n  * stocks update\n\n  or\n\n  * stocks -u\n\n  This will clone the repository and install the new versions of scripts that were installed, if you didn't install a certain tool this script will not install the new version of that tool.\n\n## Uninstalling\n\n  If you don't have the Bash-Snippets folder anymore clone the repository:  git clone https://github.com/alexanderepstein/Bash-Snippets`\n\n  cd into the Bash-Snippets directory: `cd Bash-Snippets`\n\n    To go through a guided uninstall\n\n  *  ./uninstall.sh\n\n\n## AUTHOR\n\nAlexander Epstein\nGithub: https://github.com/alexanderepstein\n\n## Contributors\n\nJake Meyer\nGithub: https://github.com/jakewmeyer\n\nLinyos Torovoltos\nGithub: https://gitbub.com/linyostorovovoltos\n\n## License\n\nMIT License\n\nCopyright (c) 2017 Alex Epstein\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n"
  },
  {
    "path": "changelog.md",
    "content": "<div align=\"center\">\n\n# Bash-Snippets Changelog\n\n## Version 1.23.0\n\n## Changes\n* Added python3 support\n* Added new feature from rates.sx for cryptocurrency\n* Added new component bak2dvd\n* Fixed stocks script and pointing it to new api\n* Fixing Wlan IP on Mac for geo\n* Adding environment variable YTVIEWPLAYER for choice of default player for ytview\n</div>\n\n<div align=\"center\">\n\n## Version 1.22.1\n\n</div>\n\n## Changes\n* Fix bugs in currency tool because of api changes\n* Fix bugs in cloudup tool because of api changes\n* Fixing movies tool\n* Fix bugs in meme tool\n* Fix default answer on install\n\n<div align=\"center\">\n\n## Version 1.22.0\n\n</div>\n\n## Changes\n* Adding bash-snippets gui component\n* Fixing bug in url shortener\n* Fixing old functionality cryptocurrency\n\n\n\n<div align=\"center\">\n\n## Version 1.21.0\n\n</div>\n\n## Changes\n* Fixing the exchange name for the stocks tool\n* Adding the memes component\n* Fixing locale error\n* Added pwned component\n* Adding one time file transfer to transfer component\n* Changing how cryptocurrency tool works now using rate.sx\n\n\n\n<div align=\"center\">\n\n## Version 1.20.0\n\n</div>\n\n## Changes\n* Brought back lyrics tool\n* Added shorten url functionality to short\n* Fixed the stocks api\n* Save QRCodes to an image file\n* Fixed bug in qrify for single-word strings\n* Adding mdfind functionality to ytview\n\n\n<div align=\"center\">\n\n## Version 1.19.2\n\n</div>\n\n## Changes\n* ytview for macOS can now use mpv\n* lyrics tool was removed, api is not available anymore\n\n\n\n<div align=\"center\">\n\n## Version 1.19.1\n\n</div>\n\n## Changes\n* Fixed bug in todo for task lists over 8 tasks\n* Fixing the endpoint in the short tool\n\n<div align=\"center\">\n\n## Version 1.19.0\n\n</div>\n\n### Changes\n* Adding BCH to cryptocurrencies tool\n* Adding lyrics component\n\n<div align=\"center\">\n\n## Version 1.18.1\n\n</div>\n\n### Changes\n* Changed how transfer uploads files\n* Upload multiple files with transfer\n* Get tasks after removal of tasks in todo\n* Bulk removal of tasks in todo\n* Removing bad echo from cloudup\n\n<div align=\"center\">\n\n## Version 1.18.0\n\n</div>\n\n### Changes\n* Added transfer component\n* Fixing fetch call across all tools\n* Changing progress echos for update\n* Run checkInternet only when needed (speeds up processes that don't need it)\n* Hiding the api help page in weather\n\n<div align=\"center\">\n\n## Version 1.17.3\n\n</div>\n\n### Changes\n* checkInternet now checks github.com over google.com\n* tools that don't need bc don't use it\n* tools that need bc can approximate without it\n* Fixing trailing quotation mark for newton on osx\n* Adding all option to uninstall\n\n\n<div align=\"center\">\n\n## Version 1.17.2\n\n</div>\n\n### Changes\n* Fixing where manpage is installed for linuxbrew\n* Updating weather usage and manpage\n\n<div align=\"center\">\n\n## Version 1.17.1\n\n</div>\n\n### Bugfixes\n* Fixing grabbing the prefix in homebrew install\n\n<div align=\"center\">\n\n## Version 1.17.0\n\n</div>\n\n### Changes\n* Adding ability to use m/s for windspeed in weather\n* Supporting httpie for all tools that work with it\n* Install for homebrew can now handle multiple tools on one line\n\n<div align=\"center\">\n\n## Version 1.16.2\n\n</div>\n\n### Changes\n* Adding back all argument to homebrew install\n\n<div align=\"center\">\n\n## Version 1.16.1\n\n</div>\n\n### Changes\n* Changed install script for homebrew\n* Added the -r option to newton\n\n<div align=\"center\">\n\n## Version 1.16.0\n\n</div>\n\n### Changes\n* Added cryptocurrency component\n* Added newton component\n* Changed WAN Call in geo\n\n<div align=\"center\">\n\n## Version 1.15.2\n\n</div>\n\n### Bugfixes\n* Installer path was preventing install\n\n<div align=\"center\">\n\n## Version 1.15.1\n\n</div>\n\n\n### Changes\n* Added --prefix option to installer for homebrew correctly\n\n<div align=\"center\">\n\n## Version 1.15.0\n\n</div>\n\n### Changes\n* Added -d option to movies\n* Updating extra tools if installed in main update pipeline\n\n<div align=\"center\">\n\n## Version 1.14.3\n\n</div>\n\n### Changes\n* Adding new progress echos to cloudup\n\n### Bugfixes\n* Fixed bug in all tools using python for OSX where it would result caught in a segfault\n\n<div align=\"center\">\n\n## Version 1.14.2\n\n</div>\n\n### Bugfixes\n* Fixing bug where cloudup was incorrectly deleting the remote bitbucket repository.\n\n<div align=\"center\">\n\n## Version 1.14.1\n\n</div>\n\n### Bugfixes\n* Fixing issue in cloudup remote url was not set correctly if the ```-t``` option was not used\n* Fixing issue in cloudup where tags were causing conflicts, solved by deleting bitbucket repo first\n\n<div align=\"center\">\n\n## Version 1.14.0\n\n</div>\n\n### Changes\n* Shebang changed to ```/usr/bin/env bash``` for more portability\n* Todo has more error checking for bad input\n* Added the ```-s``` option to cloudup which will prevent the backup of forked repositories\n* Added the ```-t``` option to cloudup to give the user the ability to create a unique repo or just update the old one\n\n<div align=\"center\">\n\n## Version 1.13.2\n\n</div>\n\n\n### Changes\n* Updated installer not allow updates if bash-snippets was installed through package manager\n\n<div align=\"center\">\n\n## Version 1.13.1\n\n</div>\n\n### Changes\n* Preventing bad input in ```todo -r```\n* Stocks was using unnecessary characters in the URL\n* Cloudup's private option now works\n* Cloudup's all option now looks to backup the first 10,000 repositories versus 100\n\n<div align=\"center\">\n\n## Version 1.13.0\n\n</div>\n\n### Changes\n* Added todo component\n\n### Bugfixes\n* Forcing ytview to search in english\n\n<div align=\"center\">\n\n## Version 1.12.0\n\n</div>\n\n### Changes\n* Added siteciphers component\n\n### Bugfixes\n* Crypt was still using only curl to get tags for update\n\n<div align=\"center\">\n\n## Version 1.11.1\n\n</div>\n\n### Changes\n* Now supporting the use of proxies\n* Typo fixes\n* Adding IMDB rating to movies tool\n\n### Bugfixes\n* Suppressing ```source ~/.bash_profile``` error\n\n\n<div align=\"center\">\n\n## Version 1.11.1\n\n</div>\n\n### Bugfixes\n* Fixed issue in ytview where it was playing wrong video\n* Fixed wget check in qrify\n\n<div align=\"center\">\n\n## Version 1.11.0\n\n</div>\n\n### Changes\n* Adding manpage, view it with ```man bash-snippets```\n\n<div align=\"center\">\n\n## Version 1.10.1\n\n</div>\n\n\n### Changes\n* Cloudup's -a option is now functional\n\n### Bugfixes\n* Cloudup only needs one temporary copy of the repository\n* Qrify had an issue where it couldn't handle more than one space\n* Cloudup now retains git history when it backs up to bitbucket\n* Fetch removed from qrify since it will not work\n\n\n<div align=\"center\">\n\n## Version 1.10.0\n\n</div>\n\n### Changes\n* Added qrify component\n\n### Bugfixes\n* Bug in taste where the -i option was not working\n* Bug in all scripts that used python on OSX\n* Bug in taste script on OSX\n\n<div align=\"center\">\n\n## Version 1.9.0\n\n</div>\n\n### Changes\n* Added cloudup component\n\n### Bugfixes\n* Fixing bug in ytview when search results are sparse\n\n\n<div align=\"center\">\n\n## Version 1.8.0\n\n</div>\n\n### Changes\n* Added ytview component\n\n### Bugfixes\n* Using ```$@``` instead of ```$1 $2 $3...``` in all applicable scripts\n* Make call to python 2 explicit in all applicable scripts\n* Hiding the cheatsheet api help page from the user\n\n\n<div align=\"center\">\n\n## Version 1.7.0\n\n</div>\n\n### Changes\n* Added cheat component\n\n<div align=\"center\">\n\n## Version 1.6.0\n\n</div>\n\n### Changes\n* Added geo component\n\n<div align=\"center\">\n\n## Version 1.5.0\n\n</div>\n\n### Changes\n* Added short component\n### Bugfixes\n* Sending errors in taste tool to /den/null\n* Taste tool only has one unique youtube link not three\n\n<div align=\"center\">\n\n## Version 1.4.0\n\n</div>\n\n# Changes\n* Added taste component\n\n<div align=\"center\">\n\n## Version 1.3.1\n\n</div>\n\n### Bugfixes\n* Fixing bug in currency where invalid exchangeTo wasn't handled correctly\n\n\n<div align=\"center\">\n\n## Version 1.3.0\n\n</div>\n\n### Changes\n* Now supporting wget, fetch and curl\n* Cleaning an echo on error for updating\n\n<div align=\"center\">\n\n## Version 1.2.1\n\n</div>\n\n### Changes\n* Check if curl is installed before using it\n* No sudo on error in update, just let user know they need to run the command as sudo\n* Changelog added\n### Bugfixes\n* Setting user agent for curl to prevent issues from changes in  ~/.curlrc\n\n<div align=\"center\">\n\n## Version 1.2.0\n\n</div>\n\n### Changes\n* Added help to each tool call with ```-h```\n* Can now call weather with metric or imperial units\n* Can now get the moon phase from weather\n* Adding locale to weather so it will return in native language\n\n<div align=\"center\">\n\n## Version 1.1.1\n\n</div>\n\n### Changes\n* Now you can pass arguments to the weather tool to get weather of a location other then your own\n* Now you can pass arguments to the currency tool to bypass the guided input\n* The output for the currency tool is cleaner\n### Bugfixes\n* Fixed bug in currency where exchange rate was not parsed correctly\n* Fixed bug in stocks where you could get lost in the tool by providing no input\n\n\n<div align=\"center\">\n\n## Version 1.1.0\n\n</div>\n\n### Changes\n* Facilitate updating by calling any of the tools with the -u option or update as the argument ex ```weather -u``` or ```weather update```\n\n<div align=\"center\">\n\n## Version 1.0.0\n\n\n</div>\n\n### Initial Release\n* Weather component added\n* Stocks component added\n* Movies component added\n* Currency component added\n* Crypt component added\n"
  },
  {
    "path": "cheat/cheat",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\n## rest of these variables are search flags\nsearch=\"0\"\ninsensitive=\"\"\nrecursive=\"\"\nboundry=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nusage()\n{\ncat <<EOF\nCheat\nDescription: Cheatsheets for quick information about multiple programming languages along with terminal commands\nUsage: cheat [flags] [command] or cheat [flags] [programming language] [subject]\n  -s  Does a search for last argument rather than looking for exact match\n  -i  Case insensitive search\n  -b  Word boundaries in search\n  -r  Recursive search\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nSpecial Pages:\n  hello      Describes building the hello world program written in the language\n  list       This lists all cheatsheets related to previous arg if none it lists all cheatsheets\n  learn      Shows a learn-x-in-minutes language cheat sheet perfect for getting started with the language\n  1line      A collection of one-liners in this language\n  weirdness  A collection of examples of weird things in this language\nExamples:\n  cheat rust hello\n  cheat -r -b -i go\n  cheat julia Functions\n  cheat -i go operators\nEOF\n}\n\ngetCheatSheet()\n{\n  if [[ $# == 1 ]]; then\n    if [[ $search == \"1\" ]]; then\n      link=cheat.sh/~$1\n    else\n      link=cheat.sh/$1\n    fi\n  else\n    link=cheat.sh/$1\n  fi\n\n  if [[ $# == 2 ]]; then\n    if [[ $search == \"1\" ]]; then\n      link+=/~$2 ## add this to end of link where ~ indicates search\n    else\n      link+=/$2 ## add this to end of link\n    fi\n  fi\n\n  if [[ $insensitive != \"\" || $recursive != \"\" || $boundry != \"\" ]]; then link+=/$boundry$insensitive$recursive; fi ## add this to the end of the link as flags\n\n  httpGet $link\n}\n\n\n### This function just wraps some of the special pages provided by cheat.sh\ncheckSpecialPage()\n{\n  temp=$1\n  if [[ $1 == \"list\" ]]; then\n    temp=\":list\"\n  elif [[ $1 == \"learn\" ]]; then\n    temp=\":list\"\n  elif [[ $1 == \"styles\" ]]; then\n    temp=\":styles\"\n  fi\n  if [[ $2 == \"1\" ]]; then\n    arg1=$temp\n  else\n    arg2=$temp\n  fi\n}\n\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"ribuvhis\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)\n        checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    i)  insensitive=\"i\"\n        search=\"1\"\n        ;;\n    b)  boundry=\"b\"\n        search=\"1\"\n        ;;\n    r)  recursive=\"r\"\n        search=\"1\"\n        ;;\n    s)  search=\"1\"\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\n### This functions sets arg 1 and arg 2 to be unqique items after the options\nfor arg; do\n  if [[ $arg != \"-r\" && $arg != \"-s\" && $arg != \"-b\" && $arg != \"-i\" ]]; then\n    if [ -z ${arg1+x} ]; then\n      arg1=$arg\n    fi\n    if [ ! -z ${arg1+x} ]; then\n      arg2=$arg\n    fi\n  fi\ndone\n\n## check for special pages before moving on\ncheckSpecialPage \"$arg1\" 1\ncheckSpecialPage \"$arg2\" 2\n\nif [[ $# == 0 ]]; then\n  usage\n  exit 0\nelif [[ $1 == \"update\" ]]; then\n  checkInternet || exit 1\n  update\n  exit 0\nelif [[ $1 == \"help\" || $1 == \":help\" ]]; then ## shows the help and prevents the user from seeing cheat.sh/:help\n  usage\n  exit 0\nelse\n  checkInternet || exit 1\n  if [[ $arg1 != $arg2 ]]; then ## if they equal each other that means there was no arg 2 supplied\n    getCheatSheet \"$arg1\" \"$arg2\"\n    exit 0\n  else\n    getCheatSheet \"$arg1\"\n    exit 0\n  fi\n  exit 0\nfi\n"
  },
  {
    "path": "cloudup/cloudup",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nprivate=\"0\" ## state of private flag\nall=\"0\" ## state of all flag\nif [ -d ~/temp ]; then rm -rf ~/temp; fi ## if the temp folder exists we want to delete it just in case it was left over from a fatal error\nsource=\"0\"\ntStamp=\"0\"\n\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\n## This grabs the users bitbucket info could be improved by making sure username exists\ngetBitbucketInfo()\n{\n  echo -n 'Enter your Bitbucket username: '\n  read bbUsername\n  if [[ $bbUsername == \"1\" ]]; then\n    echo  \"Using github username as bitbucket username\"\n    bbUsername=$ghUsername\n  fi\n  echo -n 'Enter your Bitbucket password: '\n  read -s password  # -s flag hides password text;\n  echo\n  echo\n}\n\nbackupRepo()\n{\n  cd ~/temp/github/\"$repoName\" || { echo \"Fatal error\"; return 1; }\n  repoSlug=$(echo \"$repoName\" | tr '[:upper:]' '[:lower:]')\n  if [[ $tStamp == \"0\" ]]; then { echo -n \"Attempting to delete existing bitbucket repostiory...\"; httpGet -X DELETE \"https://$bbUsername:$password@api.bitbucket.org/1.0/repositories/$bbUsername/$repoSlug\" > /dev/null || echo -n -e \"Failure!\\n\"; echo -n -e \"Success!\\n\"; }; fi ## if no timestamp then repo will not be unique we must look to delete old repo\n  if [[ $private == \"1\" ]]; then\n    echo -n \"Creating private repository for $repoName...\"\n  else\n    echo -n \"Creating public repository for $repoName...\"\n  fi\n  if [[ $tStamp == \"1\" ]]; then ## create the repository with a timestamp appended to repo name\n    timestamp=$(date | tr \" \" _ | tr : _  ) ## we do this because it takes care of changes bitbucket would have made\n    if [[ $private == \"1\" ]]; then # if so we will use --data is_private=true when creating repository\n      httpGet --user \"$bbUsername\":\"$password\" https://api.bitbucket.org/1.0/repositories/ --data name=\"$repoName\"\"$timestamp\" --data is_private=true > /dev/null || { echo -n -e \"Failure!\\n\"; echo \"Error: creating the bitbucket repo failed, most likely due to an incorrect username or password.\"; return 1; }\n    else\n      httpGet --user \"$bbUsername\":\"$password\" https://api.bitbucket.org/1.0/repositories/ --data name=\"$repoName\"\"$timestamp\" > /dev/null || { echo -n -e \"Failure!\\n\"; echo \"Error: creating the bitbucket repo failed, most likely due to an incorrect username or password.\"; return 1; }\n    fi\n    echo -n -e \"Success!\\n\"\n    echo -n \"Setting new remote url...\"\n    git remote set-url origin \"https://$bbUsername:$password@bitbucket.org/$bbUsername/$repoName$timestamp.git\" > /dev/null || { echo -n -e \"Failure!\\n\"; return 1;} ## switch the remote over to bitbucket rather than github\n  else # we are creating a reoo without a timestamp appended name\n    if [[ $private == \"1\" ]]; then # if so we will use --data is_private=true when creating repository\n      httpGet --user \"$bbUsername\":\"$password\" https://api.bitbucket.org/1.0/repositories/ --data name=\"$repoName\" --data is_private=true > /dev/null || { echo -n -e \"Failure!\\n\"; echo \"Error: creating the bitbucket repo failed, most likely due to an incorrect username or password.\"; return 1; }\n    else\n      httpGet --user \"$bbUsername\":\"$password\" https://api.bitbucket.org/1.0/repositories/ --data name=\"$repoName\" > /dev/null || { echo -n -e \"Failure!\\n\"; echo \"Error: creating the bitbucket repo failed, most likely due to an incorrect username or password.\"; return 1; }\n    fi\n    echo -n -e \"Success!\\n\"\n    echo -n \"Setting new remote url...\"\n    git remote set-url origin \"https://$bbUsername:$password@bitbucket.org/$bbUsername/$repoName.git\" > /dev/null || { echo -n -e \"Failure!\\n\"; return 1;} ## switch the remote over to bitbucket rather than github\n    echo -n -e \"Success!\\n\"\n  fi\n  echo -n \"Uploading $repoName to bitbucket..\"\n\n  git push -q  origin --all > /dev/null && touch ~/temp/github/.BSnippetsHiddenFile || { echo -n -e \"Failure!\\n\"; touch -f ~/temp/github/.BSnippetsBrokenFile; return 1; } & ## pushes al files to github and most of the repo history\n  while [[ ! -f ~/temp/github/.BSnippetsHiddenFile ]] ;do if [ -f ~/temp/github/.BSnippetsBrokenFile ];then return 1;fi && echo -n \".\" && sleep 2; done\n  rm -f ~/temp/github/.BSnippetsHiddenFile\n  echo -e -n \"Success!\\n\"\n  echo -n \"Uploading the tags for $repoName..\"\n  git push -q origin --tags > /dev/null && touch ~/temp/github/.BSnippetsHiddenFile || { echo -n -e \"Failure!\\n\"; touch -f ~/temp/github/.BSnippetsBrokenFile; return 1; } & ## have to push tags here since --tags and --all are mutually exclusive\n  while [[ ! -f ~/temp/github/.BSnippetsHiddenFile ]] ;do if [ -f ~/temp/github/.BSnippetsBrokenFile ];then return 1;fi && echo -n \".\" && sleep 2; done\n  rm -f ~/temp/github/.BSnippetsHiddenFile\n  echo -e -n \"Success!\\n\"\n  rm -rf ~/temp #if we have succesfully backedup the repo we dion't need this anymore and if we do we will recreate it\n  echo \"Successfully backed up $repoName\"\n}\n\n## When cloudup is called with no flags\ngetGitHubRepoInfo()\n{\n  echo -n 'Enter the name of the repostiory to backup: '\n  read repoName\n}\n\n## This grabs github user info could be improved upon by checking if user exists\ngetGitHubUserInfo()\n{\n  echo -n 'Enter your Github username: '\n  read ghUsername\n}\n\n## function that handles cloning a repository it uses $ghUsername and $repoName\ncloneGitHubRepo()\n{\n  echo -n \"Cloning $repoName..\"\n  validRepo=\"false\"\n  for repo in \"${repoNames[@]}\"; do\n    if [[ $repo == \"$repoName\" ]];then validRepo=\"true\" && break; fi\n  done\n  if ! $validRepo;then { echo -n -e \"Failure!\\n\"; echo \"Github repostiory is not valid (either incorrect username or repository)\"; return 1;}; fi\n  mkdir ~/temp\n  cd || { echo \"Fatal error\"; return 1; }\n  mkdir ~/temp/github || { echo \"Fatal error\"; return 1; }\n  cd ~/temp/github || { echo \"Fatal error\"; return 1; }\n  git clone -q  https://github.com/\"$ghUsername\"/\"$repoName\" && touch ~/temp/github/.BSnippetsHiddenFile || { touch ~/temp/github/.BSnippetsBrokenFile; echo -e -n \"Failure!\\n\"; return 1;} &\n  while [[ ! -f ~/temp/github/.BSnippetsHiddenFile ]] ;do if [ -f ~/temp/github/.BSnippetsBrokenFile ];then return 1;fi && echo -n \".\" && sleep 2; done\n  rm -f ~/temp/github/.BSnippetsHiddenFile\n  echo -n -e \"Success!\\n\"\n}\n\n## Grabs the last 100 updated repos and greps to grab the repository names and puts them in an array called repoNames\ngetGithubRepoNames()\n{\n  for pageNumber in {1..100}; do ## iterate through 100 possible pages\n    response=$(httpGet \"https://api.github.com/users/$ghUsername/repos?sort=updated&per_page=100&page=$pageNumber\") ## grab the original response\n    if [[ $pageNumber == \"1\" && ( $(echo \"$response\" | grep -Eo \"Not Found\") == \"Not Found\"  || $response == \"[' ']\") ]];then  { echo -e -n \"Failure!\"; echo \"Github username is invalid\"; return 1;};fi\n    repoResponse=$(echo \"$response\" | grep -Eo '\"full_name\": \"[ a-Z .  \\/ \\\\ 0-9 -- _ ]*' | sed  s/'\"full_name\": \"'/\"\"/g | sed s:\"$ghUsername\"/:: ) ## extract the repo names from the response\n    forkResponse=($(echo \"$response\" | grep -Eo '\"fork\": [a-Z]*' | cut -d \" \" -f 2 | sed  s/\"'\"//g  )) ## extract the fork status of each repo\n    count=0  ## used to iterate through the fork statuses\n    if [[ $repoResponse == \"\" ]]; then break; fi ## will only break if the page is empty\n    for repo in $repoResponse; do ## go through each repo\n      if [[ $source == \"1\" ]]; then ## if the user set the source flag\n        if [[ ${forkResponse[$count]} == \"false\" ]]; then repoNames+=(\"$repo\"); fi ## if they are the owner of the repository add it to the list of repoNames\n        count=$(( $count + 1 )) ## increment the counter\n      else ## the user didnt set the source flag\n        repoNames+=(\"$repo\") ## add all repos in repoResponse to repoNames\n      fi\n    done\n  done\n}\n\nusage()\n{\n  cat <<EOF\nCloudup\nDescription: Backs up a users github repositories to your bitbucket account.\n  With no flags cloudup will guide you through backing up a single repository\nUsage: cloudup [flags] or cloudup [flags] [listOfGHRepoNamesSplitBySpaces]\n  -p  Upload the repositor(y)(ies) as private to bitbucket (must have private\n      repo ability on bitbucket)\n  -a  Backup all github repositories\n  -s  Only backup repositories that you have created (no forks) (only works in\n      conjunction with the -a flag)\n  -t  Backup the repository with a timestamp added to the repostiory name (will\n      always create a new unique bitbucket repo)\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  cloudup\n  cloudup -p -a\n  cloudup -a -s\n  cloudup -t\n  cloudup -a -s -t -p\n  cloudup -p nameOfRepo1 nameOfRepo2\n  cloudup nameOfRepo\n  cloudup -a\nEOF\n}\n\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"tspauvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    s)  source=\"1\"  ;;\n    p)  private=\"1\" ;;\n    t)  tStamp=\"1\"  ;;\n    h)  usage\n        exit 0\n        ;;\n    a)  all=\"1\" ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $source == \"1\" && $all == \"0\" ]]; then { echo \"Error: the -s flag only works in conjunction with the -a flag.\"; exit 1; }; fi ## check if the source flag was used correctly (no need to have source flag when specifying the repositories)\nif [[ $configuredClient != \"curl\" ]]; then { echo \"Error: to use cloudup without the -t option curl must be installed\"; exit 1; }; fi ## we have to have the ability to delete an unique repo which is possible with curl -X DELETE\nif [[ $# == \"1\" ]]; then # check for keywords\n  if [[ $1 == \"update\" ]]; then\n    checkInternet || exit 1\n    update\n    exit 0\n  elif [[ $1 == \"help\" ]]; then\n    usage\n    exit 0\n  fi\nfi\n\ncheckInternet || exit 1\nif [[ $all == \"0\" ]]; then\n  if [[ ($private == \"0\" && $tStamp == \"0\" && $1 != \"\")]]; then ## checking for an arguments after possible flags if so then run through the arguments (repositories) and back them up\n    getGitHubUserInfo || exit 1\n    getGithubRepoNames || exit 1\n    getBitbucketInfo || exit 1\n    for i in \"$@\"; do ## if private is not on as a flag start rpping through them\n      repoName=$i\n      echo \"Starting to backup $repoName\"\n      cloneGitHubRepo || exit 1\n      backupRepo || { echo \"Error: couldnt backup $repoName to bitbucket\"; exit 1; }\n      echo\n    done\n    exit 0\n  elif [[ ( $private == \"0\" && $tStamp == \"0\" &&  $1 == \"\" ) || ( $private == \"1\" && $tStamp == \"0\" && $2 == \"\" ) || ( $private == \"0\" && $tStamp == \"1\" && $2 == \"\" ) || ( $private == \"1\" && $tStamp == \"1\" && $3 == \"\" )  ]]; then ## check for empty arguments after all possible flags, this will intiate a guided backup\n    getGitHubUserInfo || exit 1\n    getGithubRepoNames || exit 1\n    getGitHubRepoInfo || exit 1\n    getBitbucketInfo || exit 1\n    echo\n    cloneGitHubRepo || exit 1\n    backupRepo || { echo \"Error: couldnt backup $repoName to bitbucket\"; exit 1; }\n    exit 0\n  else ## flags are set but arguments are also provided\n    firstArg=$(( $private + $tStamp + 1 ))\n    getGitHubUserInfo || exit 1\n    getGithubRepoNames || exit 1\n    getBitbucketInfo || exit 1\n    for i in \"${@:$firstArg}\"; do\n      repoName=$i\n      echo \"Starting to backup $repoName\"\n      cloneGitHubRepo || exit 1\n      backupRepo || { echo \"Error: couldnt backup $repoName to bitbucket\"; exit 1; }\n      echo\n    done\n    exit 0\n  fi\nelse\n  getGitHubUserInfo || exit 1\n  getGithubRepoNames || exit 1\n  getBitbucketInfo || exit 1\n  echo\n  for repo in \"${repoNames[@]}\"; do\n    repoName=$repo\n    echo \"Starting to backup $repoName\"\n    cloneGitHubRepo || exit 1\n    backupRepo  || { echo \"Error: couldnt backup $repoName to bitbucket\"; exit 1; }\n    echo\n  done\n  echo \"Successfully backed up all repositories\"\n  exit 0\nfi\n"
  },
  {
    "path": "crypt/crypt",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\"\nstate=\"\"\nconfiguredClient=\"\"\n\ncheckOpenSSL()\n{\n  if  ! command -v openssl &>/dev/null; then\n    echo \"Error: to use this tool openssl must be installed\" >&2\n    return 1\n  else\n    return 0\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\n## uses openssl aes 256 cbc encryption to encrypt file salting it with password designated by user\nencrypt()\n{\n  echo \"Encrypting $1...\"\n  openssl enc -aes-256-cbc -salt -a -in \"$1\" -out \"$2\" || { echo \"File not found\"; return 1; }\n  echo \"Successfully encrypted\"\n}\n\n## uses openssl aes 256 cbc decryption to decrypt file\ndecrypt()\n{\n  echo \"Decrypting $1...\"\n  openssl enc -aes-256-cbc -d -a -in \"$1\" -out \"$2\" || { echo \"File not found\"; return 1; }\n  echo \"Successfully decrypted\"\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\n\nusage()\n{\n  cat <<EOF\nCrypt\nDescription: A wrapper around openssl that facilitates encrypting and decrypting files.\nUsage: crypt [flag] [inputFile] [outputFile]\n  -e  Encrypt the inputFile and store it in the outputFile\n  -d  Decrypt the inputFile and store it in the outputFile\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  crypt -e mySecretFile.txt myEncryptedFile.jpg (change filetype so default program is incorrect)\n  crypt -d myEncryptedFile.jpg thisIsNowDecrypted.txt (change filetype back so now default program is correct)\nEOF\n}\n\ncheckOpenSSL || exit 1\n\nwhile getopts \"huve:d:\" opt; do ## alows for using options in bash\n  case $opt in\n    e)  ## when trying to encrypt run this\n        if [[ $state != \"decrypt\" ]]; then\n          state=\"encrypt\"\n        else\n          echo \"Error: the -d and -e options are mutally exclusive\" >&2\n          exit 1\n        fi\n        if [[ $# -ne 3 ]]; then\n          echo \"Option -e needs and only accepts two arguments [file to encrypt] [output file]\" >&2\n          exit 1\n        fi\n        ;;\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    d)  ## when trying to decrypt run this\n        if [[ $state != \"encrypt\" ]]; then\n          state=\"decrypt\"\n        else\n          echo \"Error: the -e and -d options are mutally exclusive\" >&2\n          exit 1\n        fi\n        if [[ $# -ne 3 ]]; then\n          echo \"Option -d needs and only accepts two arguments [file to decrypt] [output file]\" >&2\n          exit 1\n        fi\n        ;;\n    u)  getConfiguredClient || exit 1\n        checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    :)  ## will run when no arguments are provided to to e or d options\n        echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $# == 0 ]]; then\n  usage\n  exit 0\nelif [[ $1 == \"update\" ]]; then\n  getConfiguredClient || exit 1\n  checkInternet || exit 1\n  update || exit 1\n  exit 0\nelif [[ $1 == \"help\" ]]; then\n  usage\n  exit 0\nelif [[ $state == \"encrypt\" ]]; then\n  encrypt \"$2\" \"$3\" || exit 1\n  exit 0\nelif [[ $state == \"decrypt\" ]]; then\n  decrypt \"$2\" \"$3\" || exit 1\n  exit 0\nfi\n"
  },
  {
    "path": "cryptocurrency/cryptocurrency",
    "content": "#!/usr/bin/env bash\n# Original Author: Jonas-Taha El Sesiy https://github.com/elsesiy\n# Modifications: Alexander Epstein\n\nunset base\nunset exchangeTo\nold=\"false\"\ncurrentVersion=\"1.23.0\"\nunset configuredClient\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\n## Top 10 cryptocurrencies as base\ncheckValidCurrency()\n{\n  if [[ $1 != \"BTC\" && $1 != \"ETH\" \\\n      && $1 != \"XRP\" && $1 != \"LTC\" && $1 != \"XEM\" \\\n      && $1 != \"ETC\" && $1 != \"DASH\" && $1 != \"MIOTA\" \\\n      && $1 != \"XMR\" && $1 != \"STRAT\" && $1 != \"BCH\" ]]; then\n    echo \"1\"\n  else\n    echo \"0\"\n  fi\n}\n\ncheckTargetCurrency()\n{\n  if [[ $1 != \"AUD\" && $1 != \"BRL\" \\\n      && $1 != \"CAD\" && $1 != \"CHF\" && $1 != \"CNY\" \\\n      && $1 != \"EUR\" && $1 != \"GBP\" && $1 != \"HKD\" \\\n      && $1 != \"IDR\" && $1 != \"INR\" && $1 != \"JPY\" && $1 != \"KRW\" \\\n      && $1 != \"MXN\" && $1 != \"RUB\" && $1 != \"USD\" ]]; then\n    echo \"1\"\n  else\n    echo \"0\"\n  fi\n}\n\n## Grabs the base currency from the user and validates it with all the possible currency\n## types available on the API and guides user through input (doesnt take in arguments)\ngetBase()\n{\n  echo -n \"What is the base currency: \"\n  read -r base\n  base=$(echo \"$base\" | tr /a-z/ /A-Z/)\n  if [[ $(checkValidCurrency \"$base\") == \"1\"  ]]; then\n    unset base\n    echo \"Invalid base currency\"\n    getBase\n  fi\n}\n\n## Checks base currency from the user and validates it with all the possible currency\n## types available on the API (requires argument)\ncheckBase()\n{\n  base=$1\n  base=$(echo \"$base\" | tr /a-z/ /A-Z/)\n  if [[ $(checkValidCurrency \"$base\") == \"1\" ]]; then\n    unset base\n    echo \"Invalid base currency\"\n    exit 1\n  fi\n}\n\n# Matches the symbol to the appropriate ids regarding the API calling.\ntransformBase()\n{\n  case \"$base\" in\n    \"ETH\") reqId=\"ethereum\" ;;\n    \"BTC\") reqId=\"bitcoin\" ;;\n    \"XRP\") reqId=\"ripple\" ;;\n    \"LTC\") reqId=\"litecoin\" ;;\n    \"XEM\") reqId=\"nem\" ;;\n    \"ETC\") reqId=\"ethereum-classic\" ;;\n    \"DASH\") reqId=\"dash\" ;;\n    \"MIOTA\") reqId=\"iota\" ;;\n    \"XMR\") reqId=\"monero\" ;;\n    \"STRAT\") reqId=\"stratis\" ;;\n    \"BCH\") reqId=\"bitcoin-cash\" ;;\n  esac\n}\n\n## Grabs the exchange to currency from the user and validates it with all the possible currency\n## types available on the API and guides user through input (doesnt take in arguments)\ngetExchangeTo()\n{\n  echo -n \"What currency to exchange to: \"\n  read -r exchangeTo\n  exchangeTo=$(echo \"$exchangeTo\" | tr /a-z/ /A-Z/)\n  if [[ $(checkTargetCurrency \"$exchangeTo\") == \"1\" ]]; then\n    echo \"Invalid exchange currency\"\n    unset exchangeTo\n    getExchangeTo\n  fi\n}\n\n## Grabs the exchange to currency from the user and validates it with all the possible currency\n## types available on the API (requires arguments)\ncheckExchangeTo()\n{\n  exchangeTo=$1\n  exchangeTo=$(echo \"$exchangeTo\" | tr /a-z/ /A-Z/)\n  if [[ $(checkTargetCurrency \"$exchangeTo\") == \"1\" ]]; then\n    echo \"Invalid exchange currency\"\n    unset exchangeTo\n    exit 1\n  fi\n}\n\n## Get the amount that will be exchanged and validate that the user has entered a number (decimals are allowed)\n## doesnt take in argument, it guides user through input\ngetAmount()\n{\n  echo -n \"What is the amount being exchanged: \"\n  read -r amount\n  if [[ ! \"$amount\" =~ ^[0-9]+(\\.[0-9]+)?$ ]]; then\n    echo \"The amount has to be a number\"\n    unset amount\n    getAmount\n  fi\n}\n\n## Get the amount that will be exchanged\n## validate that the user has entered a number (decimals are allowed and requires argument)\ncheckAmount()\n{\n  amount=$1\n  if [[ ! \"$amount\" =~ ^[0-9]+(\\.[0-9]+)?$ ]]; then\n    echo \"The amount has to be a number\"\n    unset amount\n    exit 1\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n## Grabs the exchange rate and does the math for converting the currency\nconvertCurrency()\n{\n  exchangeTo=$(echo \"$exchangeTo\" | tr '[:upper:]' '[:lower:]')\n  exchangeRate=$(httpGet \"https://api.coinmarketcap.com/v1/ticker/$reqId/?convert=$exchangeTo\" | grep -Eo \"\\\"price_$exchangeTo\\\": \\\"[0-9 .]*\" | sed s/\"\\\"price_$exchangeTo\\\": \\\"\"//g) > /dev/null\n  if ! command -v bc &>/dev/null; then\n    oldRate=$exchangeRate\n    exchangeRate=$(echo \"$exchangeRate\" | grep -Eo \"^[0-9]*\" )\n    amount=$(echo \"$amount\" | grep -Eo \"^[0-9]*\" )\n    exchangeAmount=$(( $exchangeRate * $amount ))\n    exchangeRate=$oldRate\n  else\n    exchangeAmount=$( echo \"$exchangeRate * $amount\" | bc )\n  fi\n  exchangeTo=$(echo \"$exchangeTo\" | tr '[:lower:]' '[:upper:]')\n\n  cat <<EOF\n=========================\n| $base to $exchangeTo\n| Rate: $exchangeRate\n| $base: $amount\n| $exchangeTo: $exchangeAmount\n=========================\nEOF\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nusage()\n{\n  cat <<EOF\nCryptoCurrency\n\nDescription: A realtime cryptocurrency converter.\nWith no flags it will pull down the latest stats of the top 10 cryptos\n\nUsage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [flag] [arg]\n   -o Utilize the old functionality of the tool\n   -f Fiat currency for conversions\n   -u Update Bash-Snippet Tools\n   -h Show the help\n   -v Get the tool version\nEOF\n}\n\n\n\n\nwhile getopts \"c:of:uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    c)\n        currency=$OPTARG\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    f)\n        fiat=$OPTARG\n        ;;\n    o)\n        old=\"true\"\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif $old;then\ngetConfiguredClient || exit 1\ngetBase # get base currency\ngetExchangeTo # get exchange to currency\ngetAmount # get the amount to be converted\ntransformBase\nconvertCurrency # grab the exhange rate and perform the conversion\nexit 0\nfi\n\n\n\nif [[ $1 == \"update\" ]]; then\n  getConfiguredClient || exit 1\n  checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n  update\n  exit 0\nelif [[ $1 == \"help\" ]]; then\n  usage\n  exit 0\nfi\n\ngetConfiguredClient || exit 1\ncheckInternet || exit 1\nlink=\"rate.sx\"\nif [[ $fiat =~ [a-zA-Z] ]]; then\n  link=\"$fiat.$link\"\nfi\n\nif [[ $currency =~ [a-zA-Z] ]]; then\n  link=\"$link/$currency\"\nfi\n\nhttpGet \"$link\"\n"
  },
  {
    "path": "currency/currency",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n# Expanded: Rohit Goswami https://github.com/HaoZeke\n\nunset base\nunset exchangeTo\ncurrentVersion=\"1.23.0\"\nunset configuredClient\ncurrencyCodes=(AUD BAM BGN BMD BND BRL CAD CHF CNY CZK DJF DKK\n  EUR GBP HKD HRK HUF IDR ISK ILS INR\n  JPY KRW MXN MYR NOK NZD PAB PHP PLN\n  RON RUB SEK SGD THB TRY USD ZAR)\n\n  ## This function determines which http get tool the system has installed and returns an error if there isnt one\n  getConfiguredClient()\n  {\n    if command -v curl &>/dev/null; then\n      configuredClient=\"curl\"\n    elif command -v wget &>/dev/null; then\n      configuredClient=\"wget\"\n    elif command -v http &>/dev/null; then\n      configuredClient=\"httpie\"\n    elif command -v fetch &>/dev/null; then\n      configuredClient=\"fetch\"\n    else\n      echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n      return 1\n    fi\n  }\n\n  peggedTo()\n  {\n    case \"$@\" in\n      BAM)  echo \"EUR:1.95583\" ;;\n      BMD)  echo \"USD:1.0\" ;;\n      BND)  echo \"SGD:1.0\" ;;\n      DJF)  echo \"USD:177.721\" ;;\n      PAB)  echo \"USD:1.0\" ;;\n      *)    echo \"1\" ;;\n    esac\n  }\n\n  ## Allows to call the users configured client without if statements everywhere\n  httpGet()\n  {\n    case \"$configuredClient\" in\n      curl)  curl -A curl -s \"$@\" ;;\n      wget)  wget -qO- \"$@\" ;;\n      httpie) http -b GET \"$@\" ;;\n      fetch) fetch -q \"$@\" ;;\n    esac\n  }\n\ncheckValidCurrency()\n{\n  if [[ \"${currencyCodes[*]}\" == *\"$(echo \"${@}\" | tr -d '[:space:]')\"* ]]; then\n    echo \"0\"\n  else\n    echo \"1\"\n  fi\n}\n\n## Grabs the base currency from the user and validates it with all the possible currency\n## types available on the API and guides user through input (doesnt take in arguments)\ngetBase()\n{\n  echo -n \"What is the base currency: \"\n  read -r base\n  base=$(echo \"$base\" | tr /a-z/ /A-Z/)\n  if [[ $(checkValidCurrency \"$base\") == \"1\" ]]; then\n    unset base\n    echo \"Invalid base currency\"\n    getBase\n  fi\n}\n\n## Checks base currency from the user and validates it with all the possible currency\n## types available on the API (requires argument)\ncheckBase()\n{\n  base=$1\n  base=$(echo \"$base\" | tr /a-z/ /A-Z/)\n  if [[ $(checkValidCurrency \"$base\") == \"1\" ]]; then\n    unset base\n    echo \"Invalid base currency\"\n    exit 1\n  fi\n}\n\n## Grabs the exchange to currency from the user and validates it with all the possible currency\n## types available on the API and guides user through input (doesnt take in arguments)\ngetExchangeTo()\n{\n  echo -n \"What currency to exchange to: \"\n  read -r exchangeTo\n  exchangeTo=$(echo \"$exchangeTo\" | tr /a-z/ /A-Z/)\n  if [[ $(checkValidCurrency \"$exchangeTo\") == \"1\" ]]; then\n    echo \"Invalid exchange currency\"\n    unset exchangeTo\n    getExchangeTo\n  fi\n}\n\n## Grabs the exchange to currency from the user and validates it with all the possible currency\n## types available on the API (requires arguments)\ncheckExchangeTo()\n{\n  exchangeTo=$1\n  exchangeTo=$(echo \"$exchangeTo\" | tr /a-z/ /A-Z/)\n  if [[ $(checkValidCurrency \"$exchangeTo\") == \"1\" ]]; then\n    echo \"Invalid exchange currency\"\n    unset exchangeTo\n    exit 1\n  fi\n}\n\n## Get the amount that will be exchanged and validate that the user has entered a number (decimals are allowed)\n## doesnt take in argument, it guides user through input\ngetAmount()\n{\n  echo -n \"What is the amount being exchanged: \"\n  read -r amount\n  if [[ ! \"$amount\" =~ ^[0-9]+(\\.[0-9]+)?$ ]]\n  then\n    echo \"The amount has to be a number\"\n    unset amount\n    getAmount\n  fi\n}\n\n## Get the amount that will be exchanged\n## validate that the user has entered a number (decimals are allowed and requires argument)\ncheckAmount()\n{\n  amount=$1\n  if [[ ! \"$amount\" =~ ^[0-9]+(\\.[0-9]+)?$ ]]\n  then\n    echo \"The amount has to be a number\"\n    unset amount\n    exit 1\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n## Grabs the exchange rate and does the math for converting the currency\nconvertCurrency()\n{\n  trueBase=$base\n  trueTarget=$exchangeTo\n  peggedBase=$( peggedTo \"$base\" )\n  peggedTarget=$( peggedTo \"$exchangeTo\" )\n  coef1=\"1\"\n  coef2=\"1\"\n  if [[ \"$peggedBase\" =~ ^[A-Z]+:[0-9.]+$ ]]; then\n    trueBase=$(echo \"$peggedBase\" | grep -Eo \"^[A-Z]*\")\n    coef1=$(echo \"$peggedBase\" | grep -Eo \"[0-9.]*$\")\n  fi\n  if [[ \"$peggedTarget\" =~ ^[A-Z]+:[0-9.]+$ ]]; then\n    trueTarget=$(echo \"$peggedTarget\" | grep -Eo \"^[A-Z]*\")\n    coef2=$(echo \"$peggedTarget\" | grep -Eo \"[0-9.]*$\")\n  fi\n  if [[ \"$trueBase\" == \"$exchangeTo\" || \"$base\" == \"$trueTarget\" ]]; then\n    exchangeRate=\"1\"\n  else\n    exchangeRate=$(httpGet \"https://api.exchangerate-api.com/v4/latest/$trueBase\" | grep -Eo \"$trueTarget\\\":[0-9.]*\" | grep -Eo \"[0-9.]*\") > /dev/null\n  fi\n  if ! command -v bc &>/dev/null; then\n    exchangeRate=$(echo \"$exchangeRate\" | grep -Eo \"^[0-9]*\" )\n    amount=$(echo \"$amount\" | grep -Eo \"^[0-9]*\" )\n    coef1=$(echo \"$coef1\" | grep -Eo \"^[0-9]*\" )\n    exchangeRate=$(( exchangeRate / coef1 ))\n    exchangeRate=$(( exchangeRate * coef2 ))\n    exchangeAmount=$(( exchangeRate * amount ))\n  else\n    exchangeRate=$( echo \"scale=8; $exchangeRate / $coef1\" | bc )\n    exchangeRate=$( echo \"$exchangeRate * $coef2\" | bc )\n    exchangeAmount=$( echo \"$exchangeRate * $amount\" | bc )\n  fi\n\n  cat <<EOF\n=========================\n| $base to $exchangeTo\n| Rate: $exchangeRate\n| $base: $amount\n| $exchangeTo: $exchangeAmount\n=========================\nEOF\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\n\nusage()\n{\n  cat <<EOF\nCurrency\nDescription: A realtime currency converter.\n   With no flags it will guide you through the currency exchange\nUsage: currency or currency [flag] or currency [base] [exchangeTo] [amount]\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nSupported Currencies:\n ______________________________\n| AUD | BGN | BRL | CAD | ZAR |\n| CHF | CNY | CZK | DKK |     |\n| EUR | GBP | HKD | HRK |     |\n| HUF | ISK | IDR | ILS |     |\n| INR | JPY | KRW | MXN |     |\n| MYR | NOK | NZD | PHP |     |\n| PLN | RON | RUB | SEK |     |\n| SGD | THB | TRY | USD |     |\n ______________________________\nExamples:\n  currency EUR USD 12.35\n  currency\nEOF\n}\n\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $# == 0 ]]; then\n  checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n  getBase # get base currency\n  getExchangeTo # get exchange to currency\n  getAmount # get the amount to be converted\n  convertCurrency # grab the exhange rate and perform the conversion\n  exit 0\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"update\" ]]; then\n    update\n  elif [[ $1 == \"help\" ]]; then\n    usage\n  else\n    echo \"Not a valid argument\"\n    usage\n    exit 1\n  fi\nelif [[ $# == \"2\" ]]; then\n  echo \"Not a valid argument\"\n  usage\n  exit 1\nelif [[ $# == \"3\" ]]; then\n  checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n  checkBase \"$1\"\n  checkExchangeTo \"$2\"\n  checkAmount \"$3\"\n  convertCurrency\n  exit 0\nelse\n  echo \"Error: too many arguments.\"\nfi\n"
  },
  {
    "path": "extras/Linux/maps/maps",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\ndirectionsFlag=\"0\"\ndirectionsMapFlag=\"0\"\nstaticMapFlag=\"0\"\nsource ~/.bash_profile 2> /dev/null ## allows grabbing enviornment variable\nMAPQUEST_API_KEY=$MAPQUEST_API_KEY\nif [ -d ~/temp ]; then rm -rf ~/temp; fi\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\n\ngetDirections()\n{\n  response=$(httpGet \"https://www.mapquestapi.com/directions/v2/route?key=$MAPQUEST_API_KEY&from=$1&to=$2&outFormat=json&ambiguities=ignore&routeType=fastest&doReverseGeocode=false&enhancedNarrative=false&avoidTimedConditions=false\")\n  firstDirection=$(echo \"$response\" | grep -Eo \"origNarrative\\\":\\\"[a-z A-Z -./0-9]*\" | grep -Eo \"[^origNarrative\\\":][a-z A-Z -./0-9]*\")\n  tempDirections=($(echo \"$response\" | grep -Eo \"\\\"narrative\\\":\\\"[a-z A-Z -./0-9]*\"))\n  distances=($(echo \"$response\" | grep -Eo \"distance\\\":[0-9]*[.][0-9]*\" | grep -Eo \"[^distance\\\":][0-9]*[.][0-9]*\"))\n  totalDist=${distances[0]}\n  count=\"0\"\n  count=\"-1\"\n  temp=${tempDirections[0]}\n  for direct in \"${tempDirections[@]}\"; do\n    if [[ $(echo \"$direct\" | grep -Eo \"narrative\") == \"narrative\" ]]; then\n      count=$(echo $count + 1 | bc)\n      directions[$count]=$temp\n      temp=$(echo \"$direct\" | grep -Eo \"[^\\\"narrative:\\\"][a-z A-Z 0-9./]*\" | sed s/'\",\"iconUrl\"'//g)\n    else\n      temp=\"$temp $direct\"\n    fi\n  done\n  #for distance in $tempDistances\n  directions[0]=$firstDirection\n}\n\ngetDirectionsMap()\n{\n  echo \"Generating route map from $unformattedFromLocation to $unformattedToLocation\"\n  mkdir ~/temp || return 1\n  httpGet \"https://www.mapquestapi.com/staticmap/v5/map?start=$1&end=$2&size=600,400@2x&key=$MAPQUEST_API_KEY\" >> ~/temp/routeImage.png || return 1\n  if [[ $(uname -s) == \"Linux\" ]]; then\n    display ~/temp/routeImage.png > /dev/null || return 1\n  elif [[ $(uname -s) == \"Darwin\" ]]; then\n    open ~/temp/routeImage.png > /dev/null\n  fi\n  rm -rf ~/temp > /dev/null\n}\n\nprintDirections()\n{\n  echo\n  echo \"From $unformattedFromLocation to $unformattedToLocation ($totalDist mi)\"\n  echo \"===================================================\"\n  count=0\n  for direct in \"${directions[@]}\"; do\n    if [ $count -ne 0 ]; then echo -n \"$(echo $count | bc)). \"; fi\n    if [[ $direct != \"\" ]]; then # sometimes original Narrative is blank\n      direct=\"$direct (${distances[$(echo $count + 1 | bc)]} mi)\"\n      if [ $count -ne 0 ]; then echo \"$direct\"; fi\n      count=$(echo $count + 1 | bc)\n    fi\n  done\n  echo \"Welcome to $unformattedToLocation\"\n  echo \"===================================================\"\n  echo\n}\n\ngetLocations()\n{\n  echo -n \"Enter your starting location: \"\n  read fromLocation\n  echo -n \"Enter your destination: \"\n  read toLocation\n  unformattedFromLocation=$fromLocation\n  unformattedToLocation=$toLocation\n  fromLocation=$(echo \"$fromLocation\" | sed s/','/\"+\"/g | sed  s/' '/\"+\"/g )\n  toLocation=$(echo \"$toLocation\" | sed s/','/\"+\"/g | sed  s/' '/\"+\"/g )\n}\n\ncheckImagemagick()\n{\n  if [[ $(uname -s) == \"Linux\" ]]; then\n    if ! command -v display &>/dev/null; then\n      echo \"Error: you need to install imagemagick to use map features.\" &>2\n      return 1\n    else\n      return 0\n    fi\n  else\n    return 0\n  fi\n}\n\ngetMapLocation()\n{\n  echo -n \"Enter the city or address you want to generate a map for: \"\n  read mapLocation\n  echo \"Generating static map for $mapLocation\"\n  mapLocation=$(echo \"$mapLocation\" | sed  s/','/\"+\"/g | sed  s/' '/\"+\"/g )\n}\n\ngetStaticMap()\n{\n  mkdir ~/temp || return 1\n  httpGet \"https://www.mapquestapi.com/staticmap/v5/map?key=$MAPQUEST_API_KEY&center=$1&zoom=15&type=hyb&size=600,400@2x\" >> ~/temp/mapImage.png || return 1\n  if [[ $(uname -s) == \"Linux\" ]]; then\n    display ~/temp/mapImage.png > /dev/null || return 1\n  elif [[ $(uname -s) == \"Darwin\" ]]; then\n    open ~/temp/mapImage.png > /dev/null || return 1\n  fi\n  rm -rf ~/temp > /dev/null || return 1\n}\n\nusage()\n{\n  cat <<EOF\nMaps\nDescription: Get directions between locations, generate static maps of locations, and generate route maps for directions.\nUsage: maps [flags]\n    -u  Update Bash-Snippet Tools\n    -d  Get directions from a location to a destination\n    -r  Generate route map (must be used with the -d flag)\n    -m  Generate static map\n          * By itself will ask for a location to generate a map\n          * In conjunction with the -d flag will generate maps for the start location and the destination\n    -h  Show the help\n    -v  Get the tool version\nExamples:\n    maps -d\n    maps -d -r -m\n    maps -m\n    maps -d -m\nEOF\n}\n\ngetConfiguredClient || exit 1\n\n## getDirections Denver Boulder || exit 1\n## printDirections Denver Boulder || exit 1\n## getDirectionsMap Denver Boulder || exit 1\n## getStaticMap Paramus || exit 1\n\nwhile getopts \"drmuvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    d)  directionsFlag=\"1\" ;;\n    m)  staticMapFlag=\"1\" ;;\n    r)  directionsMapFlag=\"1\" ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $directionsMapFlag == \"1\" && $directionsFlag == \"0\" ]]; then { echo \"Error the -r flag only works in conjunction with the -d flag.\"; exit 1; }; fi\n\nif [[ $# == 0 ]]; then\n  usage\n  exit 0\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"update\" ]]; then\n    checkInternet || exit 1\n    update\n    exit 0\n  elif [[ $1 == \"help\" ]]; then\n    usage\n    exit 0\n  fi\nfi\ncheckInternet || exit 1\nif [[ $directionsFlag == \"0\" && $staticMapFlag == \"1\" ]]; then\n  checkImagemagick || exit 1\n  getMapLocation || exit 1\n  getStaticMap \"$mapLocation\" || exit 1\nelif [[ $directionsFlag == \"1\" ]]; then\n  getLocations || exit 1\n  getDirections \"$fromLocation\" \"$toLocation\" || exit 1\n  printDirections \"$fromLocation\" \"$toLocation\" || exit 1\n  checkImagemagick || exit 1\n  if [[ $directionsMapFlag == \"1\" ]]; then getDirectionsMap \"$fromLocation\" \"$toLocation\" || exit 1; fi\n  if [[ $staticMapFlag = \"1\" ]]; then\n    echo \"Generating static map for $unformattedFromLocation\" && getStaticMap \"$fromLocation\" || exit 1\n    echo \"Generating static map for $unformattedToLocation\" && getStaticMap \"$toLocation\"  || exit 1\n  fi\nfi\n"
  },
  {
    "path": "extras/README.md",
    "content": "<div align=\"center\">\n\n# Bash-Snippets Extras\n\n</div>\n\n## Why are these here?\n\nIf there is a tool in this folder that means it is not part of the main installer pipeline\n\nIt was removed or never made it to the pipeline only for two possible reasons:\n* It is platform dependent meaning it doesn't work the same on all \\*nix machines\n* It had many dependencies that aren't native to all forms of \\*nix\n\n## Can I install these & is it safe\nYes you can install these, only tools that are considered to be fully functional will make it here. Just make sure you only install extras for the correct platform and if they require dependencies make sure to install them (although the tool itself should remind you of this)\n\n## Install\nTo install the tool just ```cd``` into the folder of the tool and run ```cp toolNameGoesHere /usr/local/bin || echo \"Run the install as sudo\" ```\n\n## Uninstall\nTo uninstall the tool just run ```rm -f /usr/local/bin/toolNameGoesHere || echo \"Run the uninstall as sudo\" ```. Notice that the recursive flag is not set so even if you accidentally go to remove ```/usr/local/bin``` the flags will not let you delete the directory.\n\n## Platform Specific Tools\n\n### Linux\n\n#### Maps\n* Provides driving directions from a certain location to another\n* Generates a route map of the trip and displays it\n* Generates maps of the from and to locations and displays them\n* The map functions require imagemagick to be installed\n\n### OSX\nNone for now\n\n## Dependent tools\nNone for now\n\n## License\nMIT License\n\nCopyright (c) 2017 Alex Epstein\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "geo/geo",
    "content": "#!/usr/bin/env bash\n\n# Bash utility for getting specific network info\n# Author: Jake Meyer\n# Github: https://github.com/jakewmeyer\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\n# Parse arguments passed + help formatting\nusage() {\n  cat <<EOF\nGeo\nDescription: Provides quick access for wan, lan, router, dns, mac, and ip geolocation data\nUsage: geo [flag]\n  -w  Returns WAN IP\n  -l  Returns LAN IP(s)\n  -r  Returns Router IP\n  -d  Returns DNS Nameserver\n  -m  Returns MAC address for interface. Ex. eth0\n  -g  Returns Current IP Geodata\nExamples:\n  geo -g\n  geo -wlrdgm eth0\nCustom Geo Output => [all] [query] [city] [region] [country] [zip] [isp]\nExample: geo -a 8.8.8.8 -o city,zip,isp\n  -o [options]  Returns Specific Geodata\n  -a [address]  For specific IP in -s\n  -v            Returns Version\n  -h            Returns Help Screen\n  -u            Updates Bash-Snippets\nEOF\n    exit\n}\n\n# Displays version number\nversion() {\n  echo \"Version $currentVersion\"\n}\n\n# Fetches WAN IP address\nwan_search() {\n  httpGet https://api.ipify.org\n}\n\n# Fetches current LAN IP address\nlan_search() {\n  if [ \"$(uname)\" = \"Darwin\" ]; then\n    ifconfig | grep -Eo 'inet (addr:)?([0-9]*\\.){3}[0-9]*' | grep -Eo '([0-9]*\\.){3}[0-9]*' | grep -v '127.0.0.1'\n  elif [ \"$(uname -s)\" = \"Linux\" ]; then\n    ip addr show | grep -Eo 'inet (addr:)?([0-9]*\\.){3}[0-9]*' | grep -Eo '([0-9]*\\.){3}[0-9]*' | grep -v '127.0.0.1'\n  else\n    echo \"OS not supported\"\n    exit 1\n  fi\n}\n\n# Fetches Router ip address\nrouter_search() {\n  if [ \"$(uname)\" = \"Darwin\" ]; then\n    netstat -rn | grep default | head -1 | awk '{print$2}'\n  elif [ \"$(uname -s)\" = \"Linux\" ]; then\n    ip route | grep ^default'\\s'via | head -1 | awk '{print$3}'\n  else\n    echo \"OS not supported\"\n    exit 1\n  fi\n}\n\n# Fetches DNS nameserver\ndns_search() {\n  if [ \"$(uname)\" = \"Darwin\" ]; then\n    grep -i nameserver /etc/resolv.conf |head -n1|cut -d ' ' -f2\n  elif [ \"$(uname -s)\" = \"Linux\" ]; then\n    cat /etc/resolv.conf | grep -i ^nameserver | cut -d ' ' -f2\n  else\n    echo \"OS not supported\"\n    exit 1\n  fi\n}\n\n# Fetches MAC address of\nmac_search() {\n  if [ \"$(uname)\" = \"Darwin\" ]; then\n    ifconfig \"$MAC\" | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'\n  elif [ \"$(uname -s)\" = \"Linux\" ]; then\n    ip addr show \"$MAC\" | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | grep -v ff:\n  else\n    echo \"OS not supported\"\n    exit 1\n  fi\n}\n\n# Fetches current geodata based on ip\ngeodata_search() {\n  httpGet \"http://ip-api.com/line/?fields=query,city,region,country,zip,isp\"\n}\n\n# Fetches specific geodata based on args\nspecific_geo() {\n  if [ \"$OPTIONS\" = \"all\" ]; then\n    httpGet \"http://ip-api.com/line/${ADDRESS}?fields=query,city,region,country,zip,isp\"\n  else\n    httpGet \"http://ip-api.com/line/${ADDRESS}?fields=${OPTIONS}\"\n  fi\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\ncheckInternet() {\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n# Option parsing \"controller\"\noptspec=\"uwlrdm:go:a:vh*:\"\nwhile getopts \"$optspec\" optchar; do\n  case \"${optchar}\" in\n    w) getConfiguredClient && checkInternet && wan_search || exit 1 ;;\n    l) lan_search ;;\n    r) router_search ;;\n    d) dns_search ;;\n    m) MAC=$OPTARG mac_search ;;\n    g) getConfiguredClient && checkInternet && geodata_search || exit 1 ;;\n    a) ADDRESS=$OPTARG ;;\n    o) getConfiguredClient && checkInternet && OPTIONS=$OPTARG specific_geo || exit 1 ;;\n    v) version ;;\n    h) usage ;;\n    u) getConfiguredClient && checkInternet && update || exit 1 ;;\n    *) usage ;;\n  esac\ndone\n\n# Makes geo command default to help screen for usability\nif [ $# -eq 0 ]; then\n  usage\n  exit 0\nelif [[ $1 == \"update\" ]]; then\n  getConfiguredClient && checkInternet && update || exit 1\nelif [[ $1 == \"help\" ]]; then\n  usage\n  exit 0\nfi\n"
  },
  {
    "path": "gist/README.md",
    "content": "# gist - Manage your gist like a pro\n\nAll your notes, scripts, config files and snippets deserve version control and tagging!  \n`gist` is a simple bash script for gist management, lite and dependency-free!  \nUse it to boost your coding workflow.\n\n- [Getting Started](#Getting-Started)\n- [Basic Commands](#Basic-Commands)\n    - [Update and clone gists from Github](#Update-and-clone-gists-from-Github)\n    - [List your gists](#List-your-gists)\n    - [Create a new gist](#Create-a-new-gist)\n    - [Modify a gist](#Modify-a-gist)\n    - [Clean unnecessary local repos](#Clean-unnecessary-local-repos)\n- [Configuration](#Configuration)\n- [Filter gists](#Filter-gists)\n    - [Filter by tags](#Filter-by-tags)\n    - [Filter by file languages](#Filter-by-file-languages)\n    - [Filter by pattern](#Filter-by-pattern)\n- [Tips](#Tips)\n    - [Filter gists with pipe](#Filter-gists-with-pipe)\n    - [Git Workflow](#Git-Workflow)\n    - [Useful action for gist repo](#Useful-action-for-gist-repo)\n    - [Suppress action](#Suppress-action)\n    - [Suppress hint](#Suppress-hint)\n\n## Getting Started\n```bash\n# Install script\ncurl -fsSL https://raw.githubusercontent.com/typebrook/gist/master/install.sh | bash\n# Fetch your gists and clone them into ~/gist as git repos\ngist fetch\n# List your gists\ngist\n# Create a new gist\ngist new\n# Create private gist with files 'foo' and 'bar'\ngist new -p foo bar\n# Check information of your third gist\ngist detail 3\n# Get the path and cd to cloned repo with subshell\ngist 3\n# List your gists with tags instead of URL\ngist tag\n# Add tags to your third gist\ngist tag 3\n# Update the description of your third gist\ngist edit 3\n# Push changes in your third gist to the remote repo\ngist push 3\n# Delete gists with indices 3, 4 and 5\ngist delete 3 4 5\n# Or use Brace Expansion\ngist delete {3..5}\n# Export your third gist as a new Github repo with web page\ngist github 3\n# For more detail, read the helper message\ngist help\n```\n\n## Basic Commands\n### Update and clone gists from Github\nRun `gist fetch` to fetch your all gists with Github API and keep short information for each gist in a index file inside a given folder. (default to `~/gist/index`)\n- Automatically Clone/Pull each gist with git into a given folder. (default to `~/gist/`)\n- Run `gist fetch star` to fetch you starred gist\n- If token is not being set, then you cannot fetch your private gist\n\n### List your gists\nRun `gist` to read index file (default to `~/gist/index`) and list your gists with the following format:\n```\n<index> <gist-URL> <files-number> <comments-number> <description>\n```\n\nlike the following:\n\n![](https://i.imgur.com/ZCLGZLW.png)\n\n- Use `gist star` to show your starred gists\n- Use `gist all` to show your and starred gists\n- Index with prefix `s` is a starred gist, index with prefix `p` is a private gist\n- There are colorful hints for each gist in the following cases:\n    - **working** \n      Some changes are made locally but not yet do `git commit`, or you are not in `master` branch\n    - **ahead**\n      Your local **HEAD** is yet to be applied to upstream\n    - **outdated**\n      Your local **HEAD** is differs from the last fetched gists, do `gist fetch` to refresh index file and pull if needed\n    \n### Create a new gist\nRun `gist new` to create a new gist\n- You can create a new gist with 3 different ways:\n    1. type the content by hand, run `gist new`\n    2. use existing files, run `gist new <file1> <file2>...`\n    3. from STDIN, like `<command> | gist new`\n- You can specify filename with `--file`, and description with `--desc`, like `gist new --file new --desc 'a new gist'`\n- If you don't specify filename or description, a prompt will shows up!\n\n### Modify a gist\nRun `gist <INDEX>` to enter sub-shell with working directory of the given gist index (by default action). You can do some trick with custom action.(See [action](#action) and [Tips](#Tips))\n\nSince now a gist is a local cloned repo, it is your business to do git commit and git push. Use `gist push <INDEX>` is not recommended.\n\n### Clean unnecessary local repos\nSay you delete gists with command `gist delete <index-of-gist>...`, the local git repositories are still at `~/gist/`. Run `gist clean` to move them into `/tmp`\n    \n## Configuration\n`gist` stores your configuraion inside `~/.config/gist.conf`, with `<key>=<value>` format for each line. And just do `source ~/.config/gist.conf` at runtime. \n\n`~/.config/gist.conf` is created automatically when you run `gist` at the first time, it only allows current user to read and write (permission 600).\n\nValid keys are [`user`](#user), [`token`](#token), [`folder`](#folder), [`auto_sync`](#auto_sync), [`action`](#action), [`EDITOR`](#EDITOR), [`protocol`](#protocol) and [`show_untagged`](#show_untagged). Use the following commands to set value:\n``` bash\n# Set key with a given value\ngist config <key> <value>\n\n# Remove current value from a key\ngist config <key>\n\n# Or just modify ~/.config/gist.conf directly\ngist config\n```\nEach key is for the following use cases:\n\n### user\nYour Github username\n\nIf you use command which needs username and `user` is not being set, a prompt will shows up and requires your username and API [`token`](#token). \n\nUse `gist config user <your-github-username>` to set the value if needed.\n\n### token\nYour Github API token for the given username. It's scope should be with `gist`.\n\nIf you use command which needs it and it is not being set, A prompt will shows up and requires it. You can choose going to web page to create a new token, or just input an existing one directly.\n\nUse `gist config toekn <your-github-api-token>` to set the value if needed.\n\n### folder \n**[Optional]** The folder you stores index file and git repos for each your gists and starred gists. Default to `~/gist/` if not being set.\n\nUse `gist config folder <prefered-directory>` to set the value if needed.\n\n### auto_sync\n**[Optional]** Automatically clone/update your gists and starred gists as git repos when doing `gist fetch`. Default to be `true`.\n\nUse `gist config auto_sync false` to disable this feature.\n\n### action\n**[Optional]** A custom action is performed when you do `gist <INDEX>` (like `gist 3` for your third gist). If is being set, `gist` will `cd` to the cloned repo, and just simply use `eval` to perform action.\n\nFor example, you can use the following command to\n**print the filename and its content of all files inside the given gist**\n```bash\ngist config action 'tail -n +1 *'\n```\n\nIf action is not being set, then a default action will be performed:\n```bash\n# Enter sub-shell with current shell or bash\n${SHELL:-bash}\n```\n\nAlso, if you run `gist <INDEX>` with `--no-action`(or `-n`), then action would be ignored.\n\n### EDITOR\n**[Optional]** Editor to open `~/.config/gist.conf`. Default to be `vi` . \n\nFor example, use `gist config EDITOR code` to use VSCode instead.\n\n### protocol\n**[Optional]** Protocol to clone git repo. Default to be `HTTPS`\n\nValid values are:\n- https\n- ssh\n\nFor example, use `gist config protocol ssh` to use SSH protocol instead.\n\n### show_untagged\n**[Optional]** Whether to show untagged gists when using [`gist tag`](#List-gists-with-tags). Default to be `true`\n\nUse `gist config show_untagged false` to disable this feature.\n\n## Filter gists\n### Filter by tags\n`gist` treats **trailing hashtags** inside gist description as tags. For example, if a description is:\n```\n[Title] this is description #tag1 #tag2\n```\nWhen [`gist`](#List-your-gists) is performed, it only display description with part: `[Title] this is description`, and treat the trailing hashtags as tags of a gist.\n\n#### Tag a gist\nYou can use the following command to add/remove tags:\n```bash\n# tag your third gist\ngist tag 3\n```\nAfter it is finished, `gist` just calls Github API to apply new description onto the given gist.\n\n#### List gists with tags\nUse sub-command `tag` to list gists with tags instead of URLs.\n```bash\n# show tags for your gists\ngist tag\n```\n![](https://i.imgur.com/6IqxQjA.png)\n\n#### Filter gists with tags\nIf arguments after `gist tag` are not indices of gist, then they will be treated as tag values. The output will be a list of gists with those tags\n```bash\n# Filter gists with tag1 and tag2\ngist tag tag1 tag2\n```\n![](https://i.imgur.com/rchqMN1.png)\n\nYou can also use regex pattern as tag value:\n```bash\n# only show tagged gists\ngist tag .+\n```\n\n#### Show existing tags\nUse sub-command `tags` to show existing tags and pinned tags. They are sorted alphabetically.\n```bash\ngist tags\n```\n![](https://i.imgur.com/PuwmaK4.png)\n\n#### Pin/Unpin tags\nSay you are working with gists with some meaningful tags. You can use sub-command `pin` to pin them, and filter your gists with pinned tags\n```bash\n# Pin tag1 and tag2, If a tag is pinned, then unpin it\ngist pin tag1 tag2\n# Disply gists with pinned tags\ngist pin\n```\n![](https://i.imgur.com/LuEjNry.png)\n\n### Filter by pattern\nYou can search gists with pattern in description, filename or file contents with sub-command `grep`\n```bash\n# search by a simple string\ngist grep string\n# search by a pattern(heading string in a line)\ngist grep '^string'\n```\n\n### Filter by file languages\n#### List gists with languages\nYou can use sub-command `lan` to List gists with file languages instead of URLs.\n```bash\n# show languages for your gists\ngist lan\n```\n![](https://i.imgur.com/QAS7ZRE.png)\n\n#### Filter gists with languages\n```bash\n# Filter gists with files in Shell and Yaml format\ngist lan LANGUAGE1 LANGUAGE2...\n```\n![](https://i.imgur.com/tKI5KND.png)\n\n### Index Range\nYou can specify the range of indices, works both on your owned gists and starred gists.\n```bash\n# only show gists with index 5 to 10\ngist 5-10\n# show gists from index 5\ngist 5-\n# show starred gists only to index s10\ngist -s10\n# only show gists with index 1 to 20\nseq 20 | gist\n```\n\n## Tips\n\n### Filter gists with pipe\nIf `STDIN` is from a pipe, then `gist` will only process gists with **indices in the first column**. So, you can concatenate the output of each sub-command.\n```bash\n# only show gists with index 1 to 20\nseq 20 | gist\n# List starred gist with Yaml file\ngist star | gist lan Yaml\n# Only List gists with tag1, pattern1 in description/filenames/contents and contains shell script\ngist tag tag1 | gist grep pattern1 | gist lan SHELL\n```\n\n### Git Workflow\nEach gist is a git repository.  \nAlthough there are some limits on `git push`, like sub-directory is prohibited. But guess what?\n1. Push another branch to `github.com` is allowed.\n2. Push tags is also allowed. And like repos in  `github.com`,  you can get source file by tag with URL:\n   ```\n   https://codeload.github.com/gist/<gist_id>/tar.gz/<tag_name>\n   ```\n \n### Useful action for gist repo\nI strongly recommend using [`tig`](https://github.com/jonas/tig) as your custom [action](#action). It is the most powerful git CLI tool as far as I know, and also easy to get in most of the Linux distros or Homebrew for mac. Give it a try!\n\nIf [`tig`](https://github.com/jonas/tig) is installed, run the following command to configure it as custom action:\n\n```bash\ngist config action 'tig -all'\n```\n`tig` interface for history diagram:\n![](https://i.imgur.com/ju37MgW.png)\n\n\n### Suppress action\nIf [`action`](#action) is not being set, you will enter sub-shell by default. If you want suppress it and do not want to type `--no-action` every time, just use command `ture` to do nothing.\n```\ngist config action 'true'\n```\n \n### Suppress hint\nThere are several environment variables or arguments can suppress hint or user confirm, like:\n```bash\n# List gists without hint\nhint=false gist\n\n# Just print the repo path with a given index\ngist 3 --no-action\n# Or shorter argument\ngist 3 -n\n\n# Delete your third gist without confirmation\ngist delete 3 --force\n```\n"
  },
  {
    "path": "gist/gist",
    "content": "#!/usr/bin/env bash\n#\n# Author: Hsieh Chin Fan (typebrook) <typebrook@gmail.com>\n# License: MIT\n# https://gist.github.com/typebrook/b0d2e7e67aa50298fdf8111ae7466b56\n#\n# --\n# gist\n# Description: Manage your gists with git and Github API v3\n# Usage: gist [command] [<args>]\n#\n#   [star|s|all|a]                List your gists, use 'star' or 's' for your starred gists,\n#                                 'all' or 'a' for both your and starred gists. Format for each line is:\n#                                 <INDEX> <URL> <FILE_NUM> <COMMENT_NUM> <DESCRIPTION>\n#   fetch,  f [star|s]            Update the local list of your gists, 'star' for your starred gists\n#   <INDEX> [-n|--no-action]         Show the path of local gist repo and do custom actions(enter sub-shell by default)\n#   new,    n [-d |--desc <description>] [-p] <FILE>...      create a new gist with files\n#   new,    n [-d |--desc <description>] [-p] [-f|--file <FILE_NAME>] create a new gist from STDIN\n#   grep,   g <PATTERN>           Grep gists by description, filename and content with a given pattern\n#   tag,    t <INDEX>             Modify tags for a gist\n#   tag,    t <TAG>...            Grep gists with tags\n#   tag,    t                     List gist with tags and pinned tags\n#   tags,   tt                    List all tags and pinned tags\n#   pin,    p <TAG>...            Pin/Unpin tags\n#   pin,    p                     Grep gists with pinned tags\n#   lan,    l <PATTERN>...        Grep gists with languages\n#   lan,    l                     List gist with languages of files\n#   detail, d <INDEX>             Show the detail of a gist\n#   edit,   e <INDEX> [\"NEW_DESCRIPTRION\"]  Edit a gist's description\n#   delete, D <INDEX>... [--force]          Delete gists by given indices\n#   push,   P <INDEX>             Push changes by git (well, better to make commit by youself)\n#   clean,  C                     Clean local repos of removed gists\n#   config, c [token|user|folder|auto_sync|EDITOR|action|protocol|show_untagged [value]]  Do configuration\n#   user,   u <USER>              Get list of gists with a given Github user\n#   github, G <INDEX>             Export selected gist as a new Github repo\n#   help,   h                     Show this help message\n#   version                       Get the tool version\n#   update                        Update Bash-Snippet Tools\n# \n# Example:\n#   gist fetch              (update the list of gists from github.com)\n#   gist                    (Show your gists)\n#   gist 3                  (show the repo path of your 3rd gist, and do custom actions)\n#   gist 3 --no-action      (show the repo path of your 3rd gist, and do not perform actions)\n#   gist new foo bari       (create a new gist with files foo and bar)\n#   gist tag                (Show your gists with tags)\n#   gist tag 3              (Add tags to your 3rd gist)\n#   gist tag .+             (show tagged gists)\n# \n# Since now a gist is a local cloned repo\n# It is your business to do git commit and git push\n\n# TODO Named temp file\n# TODO feature to exclude tag-value or grep-string\n# TODO codebase statistics, like C++ or something\n# TODO migrate to gh-page, with install.sh and check_md5 in README\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\n\nNAME=${GISTSCRIPT:-$(basename \"$0\")} #show hint and helper message with current script name\nGITHUB_API=https://api.github.com\nCONFIG=~/.config/gist.conf; mkdir -p ~/.config\n\nINDEX_FORMAT=('index' 'url' 'tags_string' 'blob_code' 'file_array' 'file_num' 'comment_num' 'author' 'created_at' 'updated_at' 'description')\nTAG_CHAR='-_[:alnum:]'\nif [[ ! -t 0 ]]; then\n  INPUT=$(cat)\n  export mark=.\nelse\n  export mark=[^s] # By defaut, only process user's gists, not starred gist\nfi\n\n# Default configuration\n[[ ! -t 1 && -z $hint ]] && hint=false\nauto_sync=true # automatically clone the gist repo\nprotocol=https\n\n# Shell configuration\nset -o pipefail\n[[ $TRACE == 'true' ]] && set -x\n\n# clean temporary files\ntmp_dir=$(mktemp -d)\ntrap \"[[ '$DEBUG' == 'true' ]] && find  $tmp_dir -type f | xargs tail -n +1 > log; rm -r $tmp_dir\" EXIT\n\n# Mac compatibility\ntmp_file() {\n  if [[ $(uname) == Darwin ]]; then \n    file=$(mktemp) && mv $(mktemp) \"$tmp_dir\" && echo \"$tmp_dir\"/$(basename \"$file\")\n  else\n    mktemp -p \"$tmp_dir\"\n  fi\n}\ntac() {\n  if [[ $(uname) == Darwin ]]; then \n    tail -r\n  else\n    $(which tac)\n  fi\n}\nmtime() {\n  if [[ $(uname) == Darwin ]]; then \n    stat -x \"$1\" | grep Modify | cut -d' ' -f2- \n  else\n    stat -c %y \"$1\"\n  fi\n}\n\n# This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient() {\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  else\n    echo \"Error: This tool requires either curl, wget, or httpie to be installed.\" >&2\n    return 1\n  fi\n}\n\n# Allows to call the users configured client without if statements everywhere\n# TODO return false if code is not 20x\nhttp_method() {\n  local METHOD=$1; shift\n  local header_opt; local header; local data_opt\n  case \"$configuredClient\" in\n    curl)   [[ -n $token ]] && header_opt=\"--header\" header=\"Authorization: token $token\"\n      [[ $METHOD =~ (POST|PATCH) ]] && data_opt='--data'\n      curl -X \"$METHOD\" -A curl -s $header_opt \"$header\" $data_opt \"@$http_data\" \"$@\" ;;\n    wget)   [[ -n $token ]] && header_opt=\"--header\" header=\"Authorization: token $token\"\n      [[ $METHOD =~ (POST|PATCH) ]] && data_opt='--body-file'\n      wget --method=\"$METHOD\" -qO- $header_opt \"$header\" $data_opt \"$http_data\" \"$@\" ;;\n    httpie) [[ -n $token ]] && header=\"Authorization:token $token\"\n      [[ $METHOD =~ (POST|PATCH) ]] && data_opt=\"@$http_data\"\n      http -b \"$METHOD\" \"$@\" \"$header\" \"$data_opt\" ;;\n  esac 2>&1 \\\n  | tee $(tmp_file) \\\n  || { echo \"Error: no active internet connection\" >&2; return 1; }\n}\n\nhttpGet() {\n  http_method GET \"$@\"\n}\n\n# Parse JSON from STDIN with string of python commands\n_process_json() {\n    PYTHONIOENCODING=utf-8 \\\n    python -c \"from __future__ import print_function; import sys, json; $1\"\n    return \"$?\"\n}\n\nupdate() {\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ $latestVersion != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ $answer == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        # shellcheck disable=SC2015\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\n# Handle configuration cases\n_configure() {\n  [[ $# == 0 ]] && (${EDITOR:-vi} \"$CONFIG\") && return 0\n\n  local valid_keys='user|token|folder|auto_sync|EDITOR|action|protocol|show_untagged'\n  local key=$1; local value=\"$2\"\n\n  [[ ! $key =~ ^($valid_keys)$ ]] \\\n  && echo \"Not a valid key for configuration, use <$valid_keys> instead.\" \\\n  && return 1\n\n  case $key in\n    user)\n      [[ -z $value ]] && echo 'Must specify username' >&2 && return 1 ;;\n    token)\n      [[ -n $value && ${#value} -ne 40 && ! $value =~ ^(\\$|\\`) ]] && echo 'Invalid token format, it is not 40 chars' >&2 && return 1 ;;\n    auto_sync | show_untagged)\n      [[ ! $value =~ ^(true|false)$ ]] && echo \"$key must be either true or false\" >&2 && return 1 ;;\n    protocol)\n      [[ ! $value =~ ^(https|ssh)$ ]] && echo 'protocol must be either https or ssh' >&2 && return 1 ;;\n    action)\n      value=\"'$2'\"\n  esac\n\n  umask 0077 && touch \"$CONFIG\"\n  local target=$key=\"$value\"\n  sed -i'' -e \"/^$key=/ d\" \"$CONFIG\" && [[ -n $target ]] && echo \"$target\" >> \"$CONFIG\"\n  cat \"$CONFIG\"\n}\n\n# Prompt for username\n_ask_username() {\n  while [[ ! $user =~ ^[[:alnum:]]+$ ]]; do\n    [[ -n $user ]] && echo \"Invalid username\"\n    read -r -p \"Github username: \" user < /dev/tty\n  done\n  _configure user \"$user\"\n}\n\n# Prompt for token\n# TODO check token scope contains gist, ref: https://developer.github.com/v3/apps/oauth_applications/#check-a-token\n_ask_token() {\n  echo -n \"Create a new token from web browser? [Y/n] \"\n  read -r answer < /dev/tty\n  if [[ ! $answer =~ ^(N|n|No|NO|no)$ ]]; then\n    python -mwebbrowser https://github.com/settings/tokens/new?scopes=gist\n  fi\n\n  while [[ ! $token =~ ^[[:alnum:]]{40}$ ]]; do\n    [[ -n $token ]] && echo \"Invalid token\"\n    read -r -p \"Paste your token here (Ctrl-C to skip): \" token < /dev/tty\n  done\n  _configure token \"$token\"\n}\n\n# Check configuration is fine with user setting\n_validate_config() {\n  # shellcheck source=/dev/null\n  source \"$CONFIG\" 2> /dev/null\n  [[ $1 =~ ^(c|config|h|help|u|user|update|version) ]] && return 0\n  if [[ -z $user ]]; then\n    echo 'Hi fellow! To access your gists, I need your Github username'\n    echo \"Also a personal token with scope which allows \\\"gist\\\"!\"\n    echo\n    _ask_username && _ask_token && init=true\n  elif [[ -z $token && $1 =~ ^(n|new|e|edit|D|delete)$ ]]; then\n    _ask_token && return 0\n    echo 'To create/edit/delete a gist, a token is needed' && return 1\n  elif [[ -z $token && $1 =~ ^(f|fetch)$ && $2 =~ ^(s|star)$ ]]; then\n    _ask_token && return 0\n    echo 'To get user starred gists, a token is needed' && return 1\n  fi\n}\n\n# Load configuration\n_apply_config() {\n  _validate_config \"$@\" || return 1\n\n  [[ -z $folder || ! -w $(dirname \"$folder\") ]] && folder=~/gist; mkdir -p $folder\n  INDEX=$folder/index; [[ -e $INDEX ]] || touch $INDEX\n  getConfiguredClient\n}\n\n# extract trailing hashtags from description\n_trailing_hashtags() {\n  grep -Eo \" #[$TAG_CHAR #]+$\" <<<\"$1\" | sed -Ee \"s/.* [$TAG_CHAR]+//g\"\n}\n\n_color_pinned_tags() {\n  local pinned_tags=( $pin )\n  pattern='('$(sed -E 's/ /[[:space:]]|/g; s/\\./[^ ]/g; s/$/[[:space:]]/' <<<\"${pinned_tags[@]/#/#}\")')'\n  sed -E -e \"s/$pattern/\\\\\\e[33m\\1\\\\\\e[0m/g\" <<<\"$1 \"\n}\n\n_color_description_title() {\n  sed -E -e 's/^\\[(.+)\\]/\\\\e[33m[\\1]\\\\e[0m/' <<<\"$1\"\n}\n\n# Return git status of a given repo\n_check_repo_status() {\n    if [[ ! -d $1 ]]; then\n      if [[ $auto_sync == 'true' ]]; then\n        echo \"\\e[32m[cloning]\\e[0m\";\n      else\n        echo \"\\e[32m[Not cloned yet]\\e[0m\";\n      fi\n    else\n      cd \"$1\" || exit 1\n      # git status is not clean or working on non-master branch\n      if [[ -n $(git status --short) || $(cat .git/HEAD) != 'ref: refs/heads/master' ]] &>/dev/null; then\n        echo \"\\e[36m[working]\\e[0m\"\n      else\n        # files contents are not the same with the last time called GIST API, so warn user to call 'gist fetch'\n        [[ $(_blob_code \"$1\") != \"$2\" ]] 2>/dev/null && local status=\"\\e[31m[outdated]\\e[0m\"\n        # current HEAD is newer than remote, warn user to call 'git push'\n        [[ -n $(git cherry) ]] 2>/dev/null && local status=\"\\e[31m[ahead]\\e[0m\"\n        echo \"$status\"\n      fi\n    fi\n}\n\n# check given index is necessary to handle\n_index_pattern() {\n  if [[ -z \"$INPUT\" ]]; then \n    echo .+\n  else\n    echo \"($(echo \"$INPUT\" | sed -Ee '/^ {4,}/ d; s/^ *//; /^$/ q' | cut -d' ' -f1 | xargs | tr ' ' '|'))\"\n  fi\n}\n\n_show_hint() {\n  if [[ $display == 'tag' && -n $pin ]]; then\n    local pinned_tags=( $pin )\n    echo > /dev/tty\n    echo Pinned tags: \"${pinned_tags[*]/#/#} \" > /dev/tty\n  elif [[ $hint != 'false' ]]; then\n    local mtime=\"$(mtime $INDEX | cut -d'.' -f1)\"\n    echo > /dev/tty\n    echo \"Last updated at $mtime\" > /dev/tty\n    echo \"Run \\\"$NAME fetch\\\" to keep gists up to date, or \\\"$NAME help\\\" for more details\" > /dev/tty\n  fi\n}\n\n# Display the list of gist, show username for starred gist\n# If hint=false, do not print hint to tty. If mark=<pattern>, filter index with regex\n# If display=tag/language, print tags/languages instead or url\n_show_list() {\n  if [[ ! -s $INDEX ]]; then\n    echo \"Index file is empty, please run commands \"\"$NAME\" fetch\" or \"\"$NAME\" create\"\"\n    return 0\n  fi\n\n  sed -Ee \"/^$mark/ !d; /^$(_index_pattern) / !d\" $INDEX \\\n  | while read -r \"${INDEX_FORMAT[@]}\"; do\n    local message=$url\n    if [[ $display == 'tag' ]]; then\n      local tags=( ${tags_string//,/ } ); message=\"${tags[@]}\"\n      [[ $show_untagged == 'false' && ${#tags[@]} == '0' ]] && continue\n      local width=45; local align=' ';\n    elif [[ $display == 'language' ]]; then\n      message=\"$(tr ',' '\\n' <<< \"$file_array\" | sed -Ee 's/.+@/#/' | uniq | xargs)\"\n      local width=45; local align=' ';\n    fi\n\n    local extra=\"$(printf \"%-4s\" \"$file_num $comment_num\")\"\n    local status=''; status=$(_check_repo_status \"$folder/${url##*/}\" \"$blob_code\")\n    [[ $index =~ ^s ]] && description=\"$(printf \"%-12s\" [\"${author}\"]) ${description}\"\n\n    raw_output=\"$(printf \"%-3s\" \"$index\") $(printf \"%${align:--}${width:-56}s\" \"$message\") $extra ${status:+${status} }$(_color_description_title \"$description\")\"\n    [[ -n $pin ]] && raw_output=\"$(_color_pinned_tags \"$raw_output\")\"\n    decorator=$(( $(grep -o '\\\\e\\[0m' <<<\"$raw_output\" | wc -l) *9 ))\n    echo -e \"$raw_output\" | cut -c -$(( $(tput cols) +decorator ))\n  done\n\n  [[ -z $INPUT ]] && _show_hint || true\n}\n\n# Grep description, filename or file content with a given pattern\n# TODO add option to configure case-sensitive\n_grep_content() {\n  if [[ -z $1 ]]; then echo 'Please give a pattern' && return 1; fi\n\n  sed -Ee \"/^$(_index_pattern) / !d\" $INDEX \\\n  | while read -r \"${INDEX_FORMAT[@]}\"; do\n    # grep from description\n    if grep --color=always -iq \"$1\" <<<\"$description\"; then\n      hint=false mark=\"$index \" _show_list\n    else\n      local repo=$folder/${url##*/}\n      [[ -d $repo ]] && cd \"$repo\" || continue\n      # grep from filenames\n      local file=$(ls \"$repo\" | grep --color=always -Ei \"$1\")\n      # grep from content of files\n      # Abort error message to prevent weird file name, for example: https://gist.github.com/6057f4a3a533f7992c60\n      local content=$(grep --color=always -EHi -m1 \"$1\" * 2>/dev/null | head -1)\n\n      [[ -n $file && file=\"$file\\n\" || -n $content ]] \\\n      && hint=false mark=\"$index \" _show_list \\\n      && echo -e \"    $file$content\"\n    fi\n  done\n}\n\n# Parse JSON object of the result of gist fetch\n_parse_gists() {\n    _process_json '\nraw = json.load(sys.stdin)\nfor gist in raw:\n    print(gist[\"html_url\"], end=\" \")\n    print(gist[\"public\"], end=\" \")\n    print(\",\".join(file[\"raw_url\"] for file in gist[\"files\"].values()), end=\" \")\n    print(\",\".join(file[\"filename\"].replace(\" \", \"-\") + \"@\" + str(file[\"language\"]).replace(\" \", \"-\") for file in gist[\"files\"].values()), end=\" \")\n    print(len(gist[\"files\"]), end=\" \")\n    print(gist[\"comments\"], end=\" \")\n    print(gist[\"owner\"][\"login\"], end=\" \")\n    print(gist[\"created_at\"], end=\" \")\n    print(gist[\"updated_at\"], end=\" \")\n    print(gist[\"description\"])\n    '\n}\n\n# Parse response from 'gist fetch' to the format for index file\n_parse_response() {\n  _parse_gists \\\n  | tac | nl -s' ' \\\n  | while read -r \"${INDEX_FORMAT[@]:0:2}\" public file_url_array \"${INDEX_FORMAT[@]:4:7}\"; do\n    local private_prefix=''; [[ $public == 'False' ]] && private_prefix=p\n    [[ -n $1 ]] && local index=${1}; index=${private_prefix}${prefix}${index}\n\n    local blob_code=$(echo \"$file_url_array\" | tr ',' '\\n' | sed -E -e 's#.*raw/(.*)/.*#\\1#' | sort | cut -c -7 | paste -s -d '-' -)\n    file_array=${file_array//@None/@Text}\n\n    local hashtags_suffix=\"$(_trailing_hashtags \"$description\")\"\n    description=\"${description%\"$hashtags_suffix\"}\"\n    local hashtags=\"$(echo \"$hashtags_suffix\" | xargs)\"\n    local tags_string=\"${hashtags// /,}\"; [[ -z $tags_string ]] && tags_string=','\n\n    eval echo \"${INDEX_FORMAT[@]/#/$}\"\n  done\n}\n\n# Get latest list of gists from Github API\n# TODO pagnation for more than 100 gists\n_fetch_gists() {\n  echo \"fetching $user's gists from $GITHUB_API...\"\n  echo\n  local route=\"users/$user/gists\"\n  local prifix=''\n  if [[ $mark == s ]]; then\n    route='gists/starred'\n    prefix=s\n  fi\n\n  result=$(http_method GET $GITHUB_API/$route?per_page=100 | prefix=$prefix _parse_response)\n  [[ -z $result ]] && echo 'Not a single valid gist' && return 0\n\n  sed -i'' -Ee \"/^$mark/ d\" $INDEX && echo \"$result\" >> $INDEX\n  hint=$hint _show_list\n\n  [[ $auto_sync == 'true' ]] && (_sync_repos &> /dev/null &)\n  true\n}\n\n# Fetch gists for a given user\n# TODO pagnation for more than 100 gists\n_query_user() {\n  local route=\"users/$1/gists\"\n  result=\"$(http_method GET $GITHUB_API/\"$route\"?per_page=100 | _parse_response)\"\n  [[ -z $result ]] && echo \"Failed to query $1's gists\" && return 1\n\n  echo \"$result\" \\\n  | while read -r \"${INDEX_FORMAT[@]}\"; do\n    echo \"$url $author $file_num $comment_num $description\" | cut -c -\"$(tput cols)\"\n  done\n}\n\n# Return the unique code for current commit, to compare repo status and the result of 'gist fetch'\n# Because there is no way to get commit SHA with 'gist fetch'\n_blob_code() {\n  cd \"$1\" && git ls-tree master | cut -d' ' -f3 | cut -c-7 | sort | paste -sd '-'\n}\n\n_pull_if_needed() {\n  sed -ne \"/$1 / p\" \"$INDEX\" \\\n  | while read -r \"${INDEX_FORMAT[@]}\"; do\n    local repo; repo=$folder/$1\n    local blob_code_local; blob_code_local=$(_blob_code \"$repo\")\n    cd \"$repo\" \\\n    && [[ $blob_code_local != \"$blob_code\" ]] \\\n    && [[ $(git rev-parse origin/master) == $(git rev-parse master) ]] \\\n    && git pull &\n  done\n}\n\n# Update local git repos\n_sync_repos() {\n  comm -1 <(ls -A \"$folder\" | sort) \\\n          <(cut -d' ' -f1-2 < \"$INDEX\" | sed -ne \"/^$mark/ s#.*/##p\" | sort) \\\n  | {\n    result=$(cat)\n\n    # clone repos which are not in the local\n    sed -ne '/^\\t/ !p' <<<\"$result\" \\\n    | xargs -I{} --max-procs 8 git clone \"$(_repo_url {})\" $folder/{} &\n\n    # if repo is cloned, do 'git pull' if remote repo has different blob objects\n    sed -ne '/^\\t/ s/\\t//p' <<<\"$result\" \\\n    | while read GIST_ID; do\n      _pull_if_needed \"$GIST_ID\"\n    done\n  }\n}\n\n# Get the url where to clone repo, take user and repo name as parameters\n_repo_url() {\n  if [[ $protocol == 'ssh' ]]; then\n    echo \"git@gist.github.com:$1.git\"\n  else\n    echo \"https://gist.github.com/$1.git\"\n  fi\n}\n\n# Get gist id from index files\n_gist_id() {\n  GIST_ID=$(sed -En -e \"/^$1 / s#^$1 [^ ]+/([[:alnum:]]+) .+#\\1#p\" $INDEX | head -1)\n  if [[ -z $GIST_ID || ! $1 =~ [0-9a-z]+ ]]; then\n    echo -e \"$(hint=false _show_list | sed -Ee 's/^( *[0-9a-z]+)/\\\\e[5m\\1\\\\e[0m/')\"\n    echo\n    echo -e \"Invalid index: \\e[33m$1\\e[0m\"\n    echo 'Use the indices blinking instead (like 1 or s1)'\n    return 1\n  fi\n}\n\n# set gist id either by given index or current directory\n_set_gist_id() {\n  if [[ -z $1 ]]; then\n    [[ $(dirname $(pwd)) == $folder ]] && GIST_ID=$(basename $(pwd)) && return 0\n  fi\n  _gist_id \"$1\" || return 1\n}\n\n# Show path of repo by gist ID, and perform action\n_goto_gist() {\n  echo \"$folder/$GIST_ID\"\n  touch \"$folder/$GIST_ID\"\n\n  if [[ $* =~ (-n|--no-action) ]]; then\n    return 0\n  elif [[ -z $action ]]; then\n    action='echo Inside subshell, press \\<CTRL-D\\> to exit; ${SHELL:-bash}'\n  fi\n\n  cd \"$folder/$GIST_ID\" && eval \"$action\"\n}\n\n# Return the path of local repo with a given index\n_goto_gist_by_index() {\n  _gist_id \"$1\" || return 1\n\n  if [[ ! -d $folder/$GIST_ID  ]]; then\n    echo 'Cloning gist as repo...'\n    if git clone \"$(_repo_url \"$GIST_ID\")\" \"$folder/$GIST_ID\"; then\n      echo 'Repo is cloned' > /dev/tty\n    else\n      echo 'Failed to clone the gist' > /dev/tty\n      return 1\n    fi\n  fi\n\n  _goto_gist \"$@\"\n}\n\n# Delete gists with given indices\n# Specify --force to suppress confirmation\n_delete_gist() {\n  if [[ ! $* =~ '--force' ]]; then\n    read -r -p \"Delete gists above? [y/N] \" response\n    response=${response,,}\n    [[ ! $response =~ ^(yes|y)$ ]] && return 0\n  fi\n\n  for i in \"$@\"; do\n    _gist_id \"$i\" &> /dev/null || continue\n    http_method DELETE \"$GITHUB_API/gists/$GIST_ID\" \\\n    && echo \"$i\" deleted \\\n    && sed -E -i'' -e \"/^$i / d\" $INDEX\n  done\n}\n\n# Remove repos which are not in index file anymore\n_clean_repos() {\n  comm -23 <(find $folder -maxdepth 1 -type d | sed -e '1d; s#.*/##' | sort) \\\n           <(cut -d' ' -f2 < \"$INDEX\" | sed -e 's#.*/##' | sort 2> /dev/null ) \\\n  | while read -r dir; do\n    mv $folder/\"$dir\" /tmp && echo $folder/\"$dir\" is moved to /tmp\n  done\n}\n\n# Parse JSON object of gist user comments\n_parse_comment() {\n  _process_json '\nraw = json.load(sys.stdin);\nfor comment in raw:\n    print()\n    print(\"|\", \"user:\", comment[\"user\"][\"login\"])\n    print(\"|\", \"created_at:\", comment[\"created_at\"])\n    print(\"|\", \"updated_at:\", comment[\"updated_at\"])\n    print(\"|\", comment[\"body\"])\n  '\n}\n\n# Show the detail of a gist\n# TODO add parameter --comment to fetch comments\n_show_detail() {\n  _set_gist_id \"$1\" || return 1\n\n  sed -En -e \"/[^ ]+ [^ ]+$GIST_ID / p\" $INDEX \\\n  | while read -r \"${INDEX_FORMAT[@]}\"; do\n    echo -e desc: $(_color_description_title \"$description\")\n    echo -e tags: ${tags_string//,/ }\n    echo -e site: https://gist.github.com/\"$GIST_ID\"\n    echo -e API : https://api.github.com/gists/\"$GIST_ID\"\n    echo -e created_at: \"$created_at\"\n    echo -e updated_at: \"$updated_at\"\n    echo -e files:\n    tr ',' '\\n' <<<\"${file_array//@/ }\" | column -t | sed -e 's/^/    /'\n  done\n}\n\n# Open Github repository import page\n_export_to_github() {\n  _gist_id \"$1\" || return 1\n  echo Put the folowing URL into web page:\n  echo -n \"https://gist.github.com/$GIST_ID.git\"\n  python -mwebbrowser https://github.com/new/import\n}\n\n# Simply commit current changes and push to remote\n_push_to_remote() {\n  if [[ ! $(pwd) =~ ^$folder/[0-9a-z]+$ ]]; then\n    _gist_id \"$1\" || return 1\n    cd \"$folder/$GIST_ID\" || exit\n  fi\n  if [[ -n $(git status --short) ]]; then\n    git add . && git commit -m 'update'\n  fi\n  if [[ -n $(git cherry) ]]; then\n    git push origin master && (hint=false _fetch_gists &> /dev/null &)\n  fi\n}\n\n# Set filename/description/permission for a new gist\n_set_gist() {\n  files=()\n  description=''; filename=''; public=True\n  while [[ -n \"$*\" ]]; do case $1 in\n    -d | --desc)\n      description=\"$2\"\n      shift; shift;;\n    -f | --file)\n      filename=\"$2\"\n      shift; shift;;\n    -p)\n      public=False\n      shift;;\n    *)\n      files+=($1)\n      shift;;\n    esac\n  done\n  ls \"${files[@]}\" > /dev/null || return 1\n}\n\n# Let user type the content of gist before setting filename\n_new_file() {\n  tmp_file=$(tmp_file)\n  if [[ -z $INPUT ]]; then \n    echo \"Type a gist. <Ctrl-C> to cancel, <Ctrl-D> when done\" > /dev/tty\n    cat > \"$tmp_file\"\n  else\n    echo \"$INPUT\" > \"$tmp_file\"\n  fi\n\n  echo > /dev/tty\n  [[ -z $1 ]] && read -e -r -p 'Type file name: ' filename < /dev/tty\n  mv \"$tmp_file\" \"$tmp_dir\"/\"$filename\"\n  echo \"$tmp_dir\"/\"$filename\"\n}\n\n# Parse JSON object of a single gist \n_gist_body() {\n  _process_json \"\nimport os.path\nfiles_json = {}\nfiles = sys.stdin.readline().split()\ndescription = sys.stdin.readline().replace('\\n','')\nfor file in files:\n    with open(file, 'r') as f:\n        files_json[os.path.basename(file)] = {'content': f.read()}\nprint(json.dumps({'public': $public, 'files': files_json, 'description': description}))\n  \"\n}\n\n# Create a new gist with files. If success, also update index file and clone the repo\n_create_gist() {\n  _set_gist \"$@\" || return 1\n  [[ -z ${files[*]} ]] && files+=($(_new_file \"$filename\"))\n  [[ -z $description ]] && read -e -r -p 'Type description: ' description < /dev/tty\n\n  echo 'Creating a new gist...'\n  http_data=$(tmp_file)\n  echo -e \"${files[*]}\\n$description\" \\\n  | _gist_body > \"$http_data\" \\\n  && http_method POST $GITHUB_API/gists \\\n  | xargs -I{} -0 echo \"[{}]\" \\\n  | _parse_response $(( $(sed -e '/^s/ d' $INDEX | wc -l) +1 )) \\\n  | tee -a $INDEX \\\n  | cut -d' ' -f2 | sed -E -e 's#.*/##' \\\n  | (xargs -I{} git clone \"$(_repo_url {})\" $folder/{} &> /dev/null &)\n\n  # shellcheck disable=2181\n  if [[ $? -eq 0 ]]; then\n    echo 'Gist is created'\n    INPUT=$(tail -1 $INDEX | cut -d' ' -f1) hint=false _show_list | tail -1\n  else\n    echo 'Failed to create gist'\n  fi\n}\n\n# Update description of a gist\n_edit_gist() {\n  local index=$1; shift\n  _gist_id \"$index\" || return 1\n\n  if [[ -z \"$@\" ]]; then\n    read -r \"${INDEX_FORMAT[@]}\" <<<\"$(sed -ne \"/^$index / p\" $INDEX)\"\n    read -e -p 'Edit description: ' -i \"$description\" -r DESC < /dev/tty\n    tags=( ${tags_string//,/ } )\n    DESC=\"$DESC ${tags[*]}\"\n  else\n    DESC=\"$@\"\n  fi\n\n  http_data=$(tmp_file)\n  echo '{' \\\"description\\\": \\\"\"${DESC//\\\"/\\\\\\\"}\"\\\" '}' > \"$http_data\"\n  new_record=$(http_method PATCH \"$GITHUB_API/gists/$GIST_ID\" \\\n               | sed -e '1 s/^/[/; $ s/$/]/' \\\n               | _parse_response \"${index#[[:alpha:]]}\" )\n  [[ -n $new_record ]] && sed -i'' -E -e \"/^$index / s^.+^$new_record^\" $INDEX \\\n  && hint=false mark=\"$index \" _show_list \\\n  || echo 'Fail to modify gist description'\n}\n\n# Print helper message\nusage() {\n  sed -Ene \"/^#/ !q; 1,/^# --/ d; s/^# //p; s/^( *|Usage: )gist/\\1$NAME/\" \"$0\"\n}\n\n# Check remote urls of all repos match current protocol in configuration file\n# If not, update them\n_check_protocol() {\n  find $folder -maxdepth 1 -mindepth 1 -type d \\\n  | while read -r repo; do\n    cd \"$repo\" || exit 1\n    url=$(git remote get-url origin)\n    if [[ $protocol == 'ssh' && $url =~ ^https ]]; then\n      git remote set-url origin \"git@gist.github.com:$(basename $(pwd)).git\"\n    elif [[ $protocol == 'https' && $url =~ ^git ]]; then\n      git remote set-url origin \"https://gist.github.com/$(basename $(pwd)).git\"\n    fi\n  done\n}\n\n_tag_gist() {\n  # if no tag is given, show gist list with tags\n  if [[ -z $* ]]; then\n    display=tag _show_list\n  # if user want to change tags of a gist\n  elif _gist_id \"$1\" &>/dev/null; then\n    _show_detail \"$1\" | sed 3,6d && echo\n    read -r \"${INDEX_FORMAT[@]}\" <<<\"$(sed -ne \"/^$1 / p\" $INDEX)\"\n    local tags=\"$(sed -e 's/,//g; s/#/ /g; s/^ //g' <<<\"$tags_string\")\"\n    read -e -p 'Edit tags: ' -i \"$tags\" -r -a new_tags < /dev/tty\n    local hashtags=( $(sed -Ee 's/#+/#/g' <<<${new_tags[@]/#/#}) ) \n    ($0 edit \"$1\" \"${description}${hashtags:+ }${hashtags[@]}\" &>/dev/null &)\n  # if user want to filter gists with given tags\n  else\n    local pattern=\"($(sed -E 's/([^ ]+)/#\\1/g; s/ /[[:space:]]|/g; s/\\./[^ ]/g' <<<\"$@\") )\"\n    hint=false mark=${INPUT:+.} display=tag _show_list | grep --color=always -E \"$pattern\"\n  fi\n}\n\n# show all tags and pinned tags\n_show_tags() {\n  local pinned_tags=( $pin )\n  local tags=$(while read -r \"${INDEX_FORMAT[@]}\"; do\n                 echo ${tags_string//,/ }\n               done < $INDEX  | tr ' ' '\\n' | sed -e '/^$/d' | sort -u) \n\n  for prefix in {0..9} {a..z} {A-Z} [^0-9a-zA-Z]; do\n    local line=$(echo \"$tags\" | grep -Eo \"#$prefix[^ ]+\" | tr '\\n' ' ')\n    [[ -z $line ]] && continue\n\n    # add color to pinned tags\n    echo -e \"$(_color_pinned_tags \"$line\")\"\n  done\n\n  echo\n  if [[ ${#pinned_tags} == 0 ]]; then\n    echo \"Run \\\"$NAME pin <tag1> <tag2>...\\\" to pin/unpin tags\"\n  else\n    echo Pinned tags: \"${pinned_tags[@]/#/#}\"\n  fi\n}\n\n# pin/unpin tags\n_pin_tags() {\n  # if no arguments, print gists with pinned tags\n  if [[ -z $* && -n $pin ]]; then\n    hint=false _tag_gist \"$pin\"\n  else\n    local new_pinned=( $(echo \"$pin\" \"$*\" | tr ' ' '\\n' | sort | uniq -u | xargs) )\n    for tag in \"${new_pinned[@]}\"; do\n      if [[ $tag =~ [p]*[0-9]+ ]]; then \n        echo Invalid tag: \"$tag\"\n        return 1\n      fi\n    done || exit 1\n\n    pin=\"${new_pinned[@]}\"\n    _show_tags\n    sed -i'' -e \"/^pin=/ d\" \"$CONFIG\" && echo pin=\\'\"${new_pinned[*]}\"\\' >> \"$CONFIG\"\n  fi\n}\n\n# show languages of files in gists\n_gists_with_languages() {\n  local pattern=\"($(sed -E 's/([^ ]+)/#\\1/g; s/ /|/g' <<<\"$@\"))\"\n  display=language _show_list | grep --color=always -Ei \"$pattern\"\n}\n\n_gists_with_range() {\n  [[ ! $* =~ ^s?[0-9]*-s?[0-9]*$ ]] && echo 'Invalid range' && exit 1\n  local prefix=''; [[ $* =~ s ]] && prefix=s\n\n  local maximum=$(sed -Ene \"/^${prefix:-[^s]}/ p\" $INDEX | wc -l)\n  local range=$(sed -Ee \"s/s//g; s/^-/1-/; s/-$/-$maximum/; s/-/ /\" <<< \"$*\")\n  INPUT=$(seq \"$range\" | sed -e \"s/^/p?$prefix/\")\n  hint=false _show_list\n}\n\n_access_last_index() {\n  GIST_ID=$(ls -tup $folder | grep / | head -1)\n  _goto_gist \"$@\"\n}\n\n_apply_config \"$@\" || exit 1\nif [[ $init ]]; then _fetch_gists; exit 0; fi\ncase \"$1\" in\n  \"\")\n    _show_list ;;\n  star | s)\n    mark=s; _show_list ;;\n  all | a)\n    mark=.; _show_list ;;\n  fetch | f)\n    [[ $2 =~ ^(s|star)$ ]] && mark=s || mark=[^s]\n    _fetch_gists ;;\n  new | n)\n    shift\n    _create_gist \"$@\" ;;\n  edit | e)\n    shift\n    _edit_gist \"$@\" ;;\n  sync | S)\n    _sync_repos ;;\n  detail | d)\n    shift\n    _show_detail \"$@\" ;;\n  delete | D)\n    shift\n    _delete_gist \"$@\" ;;\n  clean | C)\n    _clean_repos ;;\n  config | c)\n    shift\n    _configure \"$@\" && (_apply_config config && _check_protocol) ;;\n  user | u)\n    shift\n    _query_user \"$@\" ;;\n  grep | g)\n    shift\n    _grep_content \"$@\" ;;\n  github | G)\n    shift\n    _export_to_github \"$1\" ;;\n  push | P)\n    shift\n    _push_to_remote \"$1\" ;;\n  tag | t)\n    shift\n    _tag_gist \"$@\" ;;\n  tags | tt)\n    _show_tags ;;\n  pin | p)\n    shift\n    _pin_tags \"$@\" ;;\n  lan | l)\n    shift\n    _gists_with_languages \"$@\" ;;\n  *-*)\n    mark=.; _gists_with_range \"$@\" ;;\n  last | L)\n    _access_last_index \"$@\" ;;\n  version)\n    echo \"Version $currentVersion\" ;;\n  update)\n    update ;;\n  help | h)\n    usage ;;\n  *)\n    _goto_gist_by_index \"$@\" ;;\nesac\n"
  },
  {
    "path": "install.sh",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\ncurrentVersion=\"1.23.0\"\ndeclare -a tools=(bak2dvd bash-snippets cheat cloudup crypt cryptocurrency currency geo gist lyrics meme movies newton pwned qrify short siteciphers stocks taste todo transfer weather ytview)\ndeclare -a extraLinuxTools=(maps)\ndeclare -a extraDarwinTools\nusedGithubInstallMethod=\"0\"\nprefix=\"/usr/local\"\n\naskInstall()\n{\n  read -p \"Do you wish to install $1 [Y/n]: \" answer\n  answer=${answer:-Y}\n\n  if [[ \"$answer\" == [Yy] ]]; then\n    cd \"$1\" || return 1\n    echo -n \"Installing $1: \"\n    chmod a+x \"$1\"\n    cp \"$1\" /usr/local/bin > /dev/null 2>&1 || { echo \"Failure\"; echo \"Error copying file, try running install script as sudo\"; exit 1; }\n    echo \"Success\"\n    cd .. || return 1\n  fi\n}\n\nupdateTool()\n{\n  if [[ -f  /usr/local/bin/$1 ]]; then\n    usedGithubInstallMethod=\"1\"\n    cd \"$1\" || return 1\n    echo -n \"Installing $1: \"\n    chmod a+x \"$1\"\n    cp \"$1\" /usr/local/bin > /dev/null 2>&1 || { echo \"Failure\"; echo \"Error copying file, try running install script as sudo\"; exit 1; }\n    echo \"Success\"\n    cd .. || return 1\n  fi\n}\n\nextraUpdateTool()\n{\n  if [[ -f  /usr/local/bin/$1 ]]; then\n    usedGithubInstallMethod=\"1\"\n    cd extras || return 1\n    cd \"$2\" || return 1\n    cd \"$1\" || return 1\n    echo -n \"Installing $1: \"\n    chmod a+x \"$1\"\n    cp \"$1\" /usr/local/bin > /dev/null 2>&1 || { echo \"Failure\"; echo \"Error copying file, try running install script as sudo\"; exit 1; }\n    echo \"Success\"\n    cd .. || return 1\n    cd .. || return 1\n    cd .. || return 1\n  fi\n}\n\nsingleInstall()\n{\n  cd \"$1\" || exit 1\n  echo -n \"Installing $1: \"\n  chmod a+x \"$1\"\n  cp \"$1\" $prefix/bin > /dev/null 2>&1 || { echo \"Failure\"; echo \"Error copying file, try running install script as sudo\"; exit 1; }\n  echo \"Success\"\n  cd .. || exit 1\n}\n\ncopyManpage()\n{\n  manPath=\"$prefix/share/man/man1\"\n  if [ -f \"$prefix/man/man1/bash-snippets.1\" ]; then rm -f \"$prefix/man/man1/bash-snippets.1\"; fi\n  cp bash-snippets.1 $manPath 2>&1 || { echo \"Failure\"; echo \"Error copying file, try running install script as sudo\"; exit 1; }\n}\n\nresponse=$( echo \"$@\" | grep -Eo \"\\-\\-prefix\")\n\nif [[ $response == \"--prefix\" ]]; then\n  prefix=$(echo -n \"$@\" | sed -e 's/--prefix=\\(.*\\) .*/\\1/' | cut -d \" \" -f 1)\n  mkdir -p \"$prefix\"/bin \"$prefix\"/share/man/man1\n  if [[ $2 == \"all\" ]];then\n    for tool in \"${tools[@]}\"; do\n      singleInstall \"$tool\" || exit 1\n    done\n  else\n    for tool in \"${@:2}\"; do\n      singleInstall \"$tool\" || exit 1\n    done\n  fi\n  copyManpage || exit 1\nelif [[ $# == 0 ]]; then\n  for tool in \"${tools[@]}\"; do\n    askInstall \"$tool\" || exit 1\n  done\n  copyManpage || exit 1\nelif [[ $1 == \"update\" ]]; then\n  echo \"Updating scripts...\"\n  for tool in \"${tools[@]}\"; do\n    updateTool \"$tool\" || exit 1\n  done\n  if [[ $(uname -s) == \"Linux\" ]]; then\n    for tool in \"${extraLinuxTools[@]}\"; do\n      extraUpdateTool \"$tool\" Linux || exit 1\n    done\n  fi\n  if [[ $(uname) == \"Darwin\" ]];then\n    for tool in \"${extraDarwinTools[@]}\"; do\n      extraUpdateTool \"$tool\" Darwin || exit 1\n    done\n  fi\n  if [[ $usedGithubInstallMethod == \"1\" ]]; then\n    copyManpage || exit 1\n  else\n    echo \"It appears you have installed bash-snippets through a package manager, you must update it with the respective package manager.\"\n    exit 1\n  fi\nelif [[ $1 == \"all\" ]]; then\n  for tool in \"${tools[@]}\"; do\n    singleInstall \"$tool\" || exit 1\n  done\n  copyManpage || exit 1\nelse\n  singleInstall \"$1\" || exit 1\n  copyManpage || exit 1\nfi\n\necho -n \"( •_•)\"\nsleep .75\necho -n -e \"\\r( •_•)>⌐■-■\"\nsleep .75\necho -n -e \"\\r               \"\necho  -e \"\\r(⌐■_■)\"\nsleep .5\necho \"Bash Snippets version $currentVersion\"\necho  \"https://github.com/alexanderepstein/Bash-Snippets\"\n"
  },
  {
    "path": "lyrics/lyrics",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nartist=\"false\"\nsong=\"false\"\nfilePath=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\ngetConfiguredPython()\n{\n  if command -v python3 &>/dev/null; then\n    configuredPython=\"python3\"\n  elif  command -v python2 &>/dev/null; then\n    configuredPython=\"python2\"\n  elif command -v python &>/dev/null; then\n    configuredPython=\"python\"\n  else\n    echo \"Error: This tool requires python to be installed.\"\n    return 1\n  fi\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then\n  python()\n  {\n    case \"$configuredPython\" in\n      python3) python3 \"$@\" ;;\n      python2) python2 \"$@\" ;;\n      python)  python \"$@\" ;;\n    esac\n  }\nfi\n\n## Grabs an element from a a json string and then echoes it to stdout\n## $1 = the JSON string\n## $n+1 = the elements to be indexed\nAccessJsonElement() {\n  json=\"$1\"\n  shift\n  accessor=\"\"\n  for element in \"$@\"; do\n      accessor=\"${accessor}['$element']\"\n  done\n  echo \"$json\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)${accessor})\" 2> /dev/null\n  return \"$?\"\n}\n\n\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 1.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        git clone \"https://github.com/$githubUserName/$repositoryName\" || { echo \"Couldn't download latest version\"; exit 1; }\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\ngetLyrics()\n{\n  encodedArtist=$(echo \"$1\" | sed s/\" \"/%20/g | sed s/\"&\"/%26/g | sed s/,/%2C/g | sed s/-/%2D/g)\n  encodedSong=$(echo \"$2\" | sed s/\" \"/%20/g | sed s/\"&\"/%26/g | sed s/,/%2C/g | sed s/-/%2D/g)\n  response=$(httpGet \"https://api.lyrics.ovh/v1/$encodedArtist/$encodedSong\")\n  lyrics=\"$(AccessJsonElement \"$response\" \"lyrics\" 2> /dev/null)\"\n  if [[ $lyrics == \"\" ]];then { echo \"Error: no lyrics found!\"; return 1; }; fi\n}\n\nprintLyrics()\n{\n  if [[ $filePath == \"\" ]];then echo -e \"$lyrics\"\n  else\n    if [ -f \"$filePath\" ];then\n      echo -n \"File already exists, do you want to overwrite it [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        echo -e \"$lyrics\" > \"$filePath\";\n      fi\n    else\n        echo -e \"$lyrics\" > \"$filePath\";\n    fi\n   fi\n}\n\nusage()\n{\n  cat <<EOF\nLyrics\nDescription: Fetch lyrics for a certain song.\nUsage: lyrics [flags] or tool [-a] [arg] [-s] [arg]\n  -a  Artist of the song to fetch lyrics for\n  -s  Song of the artist to fetch lyrics for\n  -f  Export the lyrics to file rather than outputting to stdout\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n   lyrics -a logic -s run it\n   lyrics -a logic -s run it -f ~/runItLyrics.txt\nEOF\n}\n\n\nwhile getopts \"f:a:s:uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)\n        getConfiguredClient || exit 1\n        checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    f)\n       filePath=\"$OPTARG\"\n        ;;\n    a)\n        artist=\"true\"\n        if [[ \"$(echo \"$@\" | grep -Eo \"\\-s\")\" == \"-s\" ]];then song=\"true\";fi # wont go through both options if arg spaced and not quoted this solves that issue (dont need this but once had bug on system where it was necessary)\n        if [[ \"$(echo \"$@\" | grep -Eo \"\\-f\")\" == \"-f\" ]];then filePath=$(echo \"$@\" | grep -Eo \"\\-f [ a-z A-Z / 0-9 . \\ ]*[ -]?\" | sed s/-f//g | sed s/-//g | sed s/^\" \"//g);fi\n      ;;\n    s)\n        song=\"true\"\n        if [[ \"$(echo \"$@\" | grep -Eo \"\\-a\")\" == \"-a\" ]];then artist=\"true\";fi # wont go through both options if arg spaced and not quoted this solves that issue (dont need this but once had bug on system where it was necessary)\n        if [[ \"$(echo \"$@\" | grep -Eo \"\\-f\")\" == \"-f\" ]];then filePath=$(echo \"$@\" | grep -Eo \"\\-f [ a-z A-Z / 0-9 . \\ ]*[ -]?\" | sed s/-f//g | sed s/-//g | sed s/^\" \"//g);fi\n      ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\n# special set of first arguments that have a specific behavior across tools\nif [[ $# == \"0\" ]]; then\n  usage ## if calling the tool with no flags and args chances are you want to return usage\n  exit 0\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"update\" ]]; then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    update || exit 1\n    exit 0\n  elif [[ $1 == \"help\" ]]; then\n    usage\n    exit 0\n  fi\nfi\n\nif ($artist && ! $song)  || ($song && ! $artist);then\n  echo \"Error: the -a and the -s flag must be used to fetch lyrics.\"\n  exit 1\nelif $artist && $song;then\n  song=$(echo \"$@\" | grep -Eo \"\\-s [ a-z A-Z 0-9 . \\ ]*[ -]?\" | sed s/-s//g | sed s/-//g | sed s/^\" \"//g)\n  if [[ $song == \"\" ]];then { echo \"Error: song could not be parsed from input.\"; exit 1; };fi\n  artist=$(echo \"$@\" | grep -Eo \"\\-a [ a-z A-Z 0-9 . \\ ]*[ -]?\" | sed s/-a//g | sed s/-//g | sed s/^\" \"//g)\n  if [[ $artist == \"\" ]];then { echo \"Error: artist could not be parsed from input.\"; exit 1; };fi\n  getConfiguredClient || exit 1\n  if [[ $(uname) != \"Darwin\" ]]; then getConfiguredPython || exit 1;fi\n  checkInternet || exit 1\n  getLyrics \"$artist\" \"$song\" || exit 1\n  printLyrics\nelse\n  { clear; echo \"You shouldnt be here but maaaaaaybeee you slipped passed me, learn to use the tool!\"; sleep 5; clear;}\n  usage\n  exit 1\nfi\n"
  },
  {
    "path": "meme/meme",
    "content": "#!/usr/bin/env bash\n# Author: Navan Chauhan https://github.com/navanchauhan\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nfileName=\"\"\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -Ls \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 1.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        git clone \"https://github.com/$githubUserName/$repositoryName\" || { echo \"Couldn't download latest version\"; exit 1; }\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nmain(){\n    echo -n \"Enter the name for the meme's background (Ex. buzz, doge, blb ): \"\n    read bg\n    echo -n \"Enter the text for the first line: \"\n    read raw_first\n    almost_first=$(echo \"$raw_first\" | awk '{print tolower($0)}')\n    first=$(echo \"$almost_first\" | sed -e 's/ /_/g')\n    echo -n \"Enter the text for the second line: \"\n    read raw_second\n    almost_second=$(echo \"$raw_second\" | awk '{print tolower($0)}')\n    second=$(echo \"$almost_second\" | sed -e 's/ /_/g')\n    if [ -z \"$first\" ]\n    then\n    first=$(echo \"_\")\n    else\n      echo \"\"\n    fi\n    if [ -z \"$second\" ]\n    then\n    second=$(echo \"_\")\n    else\n      echo \"\"\n    fi\n    httpGet \"https://memegen.link/$bg/$first/$second.jpg\"  >> \"$fileName\".png || return 1\n    return 0\n}\n\nusage()\n{\n  cat <<EOF\nMeme\nDescription: A lightning fast meme generator\nUsage: tool [flags] or tool [flags] [arguments]\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -f  Choose the output filename\n  -v  Get the tool version\nExamples:\n   meme -h\n   meme -f dogeMeme\nEOF\n}\n\n\n\nwhile getopts \"uvhf:\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  getConfiguredClient || exit 1\n        checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    f)\n        fileName=$OPTARG\n        getConfiguredClient || exit 1\n        checkInternet || exit 1\n        main || exit 1\n        exit 0\n    ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\n\n\n\n# special set of first arguments that have a specific behavior across tools\nif [[ $# == \"0\" ]]; then\n  getConfiguredClient || exit 1\n  checkInternet || exit 1\n  if [[ $fileName == \"\" ]]; then\n    fileName=\"meme\"\n  fi\n  main || exit 1\n  exit 0\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"update\" ]]; then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    update || exit 1\n    exit 0\n  elif [[ $1 == \"help\" ]]; then\n    usage\n    exit 0\n  fi\nfi\n"
  },
  {
    "path": "movies/movies",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nconfiguredPython=\"\"\ndetail=false\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ngetConfiguredPython()\n{\n  if command -v python3 &>/dev/null; then\n    configuredPython=\"python3\"\n  elif  command -v python2 &>/dev/null; then\n    configuredPython=\"python2\"\n  elif command -v python &>/dev/null; then\n    configuredPython=\"python\"\n  else\n    echo \"Error: This tool requires python to be installed.\"\n    return 1\n  fi\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then\n  python()\n  {\n    case \"$configuredPython\" in\n      python3) python3 \"$@\" ;;\n      python2) python2 \"$@\" ;;\n      python)  python \"$@\" ;;\n    esac\n  }\nfi\n\n## Grabs an element from a a json string and then echoes it to stdout\n## $1 = the JSON string\n## $n+1 = the elements to be indexed\nAccessJsonElement() {\n  json=\"$1\"\n  shift\n  accessor=\"\"\n  for element in \"$@\"; do\n      accessor=\"${accessor}['$element']\"\n  done\n  echo \"$json\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)${accessor})\" 2> /dev/null\n  return \"$?\"\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n## This function grabs information about a movie and using python parses the\n## JSON response to extrapolate the information for storage\ngetMovieInfo()\n{\n  apiKey=e3aeac39 # try not to abuse this it is a key that came from the ruby-scripts repo I link to.\n  movie=$( (echo \"$@\" | tr \" \" + ) | sed 's/-d+//g' ) ## format the inputs to use for the api. Added sed command to filter -d flag.\n  export PYTHONIOENCODING=utf8 #necessary for python in some cases\n  movieInfo=$(httpGet \"http://www.omdbapi.com/?t=$movie&apikey=$apiKey\") > /dev/null # query the server and get the JSON response\n\n  ## check to see if the movie was found\n  checkResponse=$(echo \"$movieInfo\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Response'])\" 2> /dev/null)\n  if [[ $checkResponse == \"False\" ]]; then\n    echo \"$movieInfo\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Error'])\" 2> /dev/null\n    return 1\n  fi\n\n  # The rest of the code is just extrapolating the data with python from the JSON response\n  title=\"$(AccessJsonElement \"$movieInfo\" \"Title\")\"\n  year=\"$(AccessJsonElement \"$movieInfo\" \"Year\")\"\n  runtime=\"$(AccessJsonElement \"$movieInfo\" \"Runtime\")\"\n  imdbScore=$(echo \"$movieInfo\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Ratings'][0]['Value'])\" 2> /dev/null)\n  tomatoScore=$(echo \"$movieInfo\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Ratings'][1]['Value'])\" 2> /dev/null)\n  rated=\"$(AccessJsonElement \"$movieInfo\" \"Rated\")\"\n  genre=\"$(AccessJsonElement \"$movieInfo\" \"Genre\")\"\n  director=\"$(AccessJsonElement \"$movieInfo\" \"Director\")\"\n  actors=\"$(AccessJsonElement \"$movieInfo\" \"Actors\")\"\n  plot=\"$(AccessJsonElement \"$movieInfo\" \"Plot\")\"\n  \n  if $detail; then\n    awards=\"$(AccessJsonElement \"$movieInfo\" \"Awards\")\"\n    boxOffice=\"$(AccessJsonElement \"$movieInfo\" \"BoxOffice\")\"\n    metacriticScore=$(echo \"$movieInfo\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Ratings'][2]['Value'])\" 2> /dev/null)\n    production=\"$(AccessJsonElement \"$movieInfo\" \"Production\")\"\n  fi\n}\n\n# Print key: value info\nprintKV() {\n  key=$1\n  val=$2\n  ROW=\"|%11s: %-40s|\\n\"\n  WIDTH=53\n\n  # If value too long (greater then 43 char), split it into several line\n  if [[ ${#val} -le $((WIDTH - 10)) ]]; then\n    printf \"$ROW\" \"$key\" \"$val\"\n  else\n    printf \"$ROW\" \"$key\"\n    printf \"%s\\n\" \"$val\" | fmt -w 50 \\\n    | while IFS= read -r line; do printf \"|  %-50s |\\n\" \"$line\"; done\n  fi\n}\n\n# Prints the movie information out in a human readable format\nprintMovieInfo()\n{\n  echo\n  echo '+=====================================================+'\n  printKV \"Title\" \"$title\"\n  printKV \"Year\" \"$year\"\n  printKV \"Runtime\" \"$runtime\"\n  if [[ $imdbScore != \"\" ]]; then printKV \"IMDB\" \"$imdbScore\"; fi\n  if [[ $tomatoScore != \"\" ]]; then printKV \"Tomato\" \"$tomatoScore\"; fi\n  if $detail; then\n    if [[ $metacriticScore != \"\" ]]; then printKV \"Metascore\" \"$metacriticScore\"; fi\n  fi\n  if [[ $rated != \"N/A\" && $rated != \"\" ]]; then printKV \"Rated\" \"$rated\"; fi\n  printKV \"Genre\" \"$genre\"\n  printKV \"Director\" \"$director\"\n  printKV \"Actors\" \"$actors\"\n  if [[ $plot != \"N/A\" && $plot != \"\" ]]; then printKV \"Plot\" \"$plot\"; fi\n  if $detail; then\n    if [[ $boxOffice != \"\" ]]; then printKV \"BoxOffice\" \"$boxOffice\"; fi\n    if [[ $production != \"\" ]]; then printKV \"Production\" \"$production\"; fi\n    if [[ $awards != \"\" ]]; then printKV \"Awards\" \"$awards\"; fi\n  fi\n  echo '+=====================================================+'\n  echo\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nusage()\n{\n  cat <<EOF\nMovies\nDescription: Provides relevant information about a certain movie.\nUsage: movies [flag] or movies [movieToSearch]\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\n  -d  Show detailed information\nExamples:\n  movies Argo\n  movies Inception\nEOF\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then getConfiguredPython || exit 1; fi\ngetConfiguredClient || exit 1\n\n\nwhile getopts 'ud:hv' flag; do\n  case \"${flag}\" in\n    u) checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n      update\n       exit 0 ;;\n    d) detail=true ;;\n    h) usage\n       exit 0 ;;\n    v) echo \"Version $currentVersion\"\n       exit 0 ;;\n    :) echo \"Option -$OPTARG requires an argument.\" >&2\n       exit 1 ;;\n    *) exit 1 ;;\n  esac\ndone\n\nif [[ $# == 0 ]]; then\n  usage\nelif [[ $1 == \"update\" ]]; then\n  checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n  update\nelif [[ $1 == \"help\" ]]; then\n  usage\nelse\n  checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n  getMovieInfo \"$@\" || exit 1 ## exit if we return 1 (chances are movie was not found)\n  printMovieInfo ## print out the data\nfi\n"
  },
  {
    "path": "movies/tmdb",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n# Author: Navan Chauhan https://github.com/navanchauhan\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nconfiguredPython=\"\"\nAPIKEY=\"b2f8880475c888056b6207067fbaa197\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ngetConfiguredPython()\n{\n  if  command -v python2 &>/dev/null ; then\n    configuredPython=\"python2\"\n  elif command -v python &>/dev/null ; then\n    configuredPython=\"python\"\n  else\n    echo \"Error: This tool requires python 2 to be installed.\"\n    return 1\n  fi\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then\n  python()\n  {\n    case \"$configuredPython\" in\n      python2) python2 \"$@\";;\n      python) python \"$@\";;\n    esac\n  }\nfi\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 1.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]];then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd  ~ || { echo 'Update Failed' ; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        git clone \"https://github.com/$githubUserName/$repositoryName\" || { echo \"Couldn't download latest version\" ; exit 1; }\n        cd $repositoryName ||  { echo 'Update Failed' ; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nprintMovieInfo()\n{\n  echo\n  echo \"==========================================\"\n  echo \"| Title: $name\"\n  echo \"| Language: $language\"\n  echo \"| Genre: $genres\"\n  echo \"| Runtime: $runtime mins\"\n  echo \"| User Rating: $voteAverage/10.0 with $voteCount votes\"\n  echo \"| Plot: $plot\"\n  echo \"==========================================\"\n  echo\n}\n\nusage()\n{\n  cat <<EOF\nMovies\nDescription: Provides relevant information about a certain movie.\nUsage: movies [flag] or movies [movieToSearch]\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  movies Argo\n  movies Inception\nEOF\n}\n\ngetMovieInfo()\n{\n  title=$1\n  encodedTitle=$( echo \"$title\" | sed 's/ /%20/g' );\n  movieSearchInfo=$( httpGet \"https://api.themoviedb.org/3/search/movie?query=$encodedTitle&language=en-US&api_key=$APIKEY\")\n  movieID=$(echo \"$movieSearchInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['results'][0]['id']\" 2> /dev/null)\n  if [[ $movieID == \"\" ]];then { echo \"Error: could not find a movie matching the title $title\"; return 1; }; fi\n  movieInfo=$(httpGet \"https://api.themoviedb.org/3/movie/$movieID?api_key=$APIKEY\")\n  name=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['original_title']\" 2> /dev/null )\n  plot=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['overview']\" 2> /dev/null )\n  language=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['original_language']\" 2> /dev/null )\n  runtime=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['runtime']\" 2> /dev/null )\n  voteCount=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['vote_count']\" 2> /dev/null )\n  genreOne=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['genres'][0]['name']\" 2> /dev/null )\n  genreTwo=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['genres'][1]['name']\" 2> /dev/null )\n  genreThree=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['genres'][2]['name']\" 2> /dev/null )\n  genres=$(echo \"$genreOne $genreTwo $genreThree\" | tr \" \" \",\")\n  voteAverage=$(echo \"$movieInfo\" | python -c \"import sys, json; print json.load(sys.stdin)['vote_average']\" 2> /dev/null )\n}\n\ngetConfiguredClient || exit 1\nif [[ \"$(uname)\" == \"Linux\" ]];then getConfiguredPython || exit 1; fi\ncheckInternet || exit 1\n\n\nwhile getopts 'uhv' flag; do\n  case \"${flag}\" in\n    u) update\n       exit 0 ;;\n    h) usage\n       exit 0 ;;\n    v) echo \"Version $currentVersion\"\n       exit 0 ;;\n    :) echo \"Option -$OPTARG requires an argument.\" >&2\n       exit 1 ;;\n    *) exit 1 ;;\n  esac\ndone\n\nif [[ $# == 0 ]]; then\n  usage\nelif [[ $1 == \"update\" ]]; then\n  update\nelif [[ $1 == \"help\" ]]; then\n  usage\nelse\n  getMovieInfo \"$@\" || exit 1 ## exit if we return 1 (chances are movie was not found)\n  printMovieInfo ## print out the data\nfi\n"
  },
  {
    "path": "newton/newton",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nflagCount=\"0\"\ndeclare -a simpleOperations=(simplify factor derive integrate zeroes roots tangent area cos sin tan arccos arcsin arctan abs log)\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nvalidateExpression()\n{\n  local parsedExpression # only used here\n  originalEquation=$(echo \"$1\" | sed \"s/\\[/\\(/g\" | sed \"s/\\]/\\)/g\") # accont for the fact that we have to use brackets and not parenthesis\n  parsedExpression=$(echo \"$1\" | sed \"s/\\[/\\(/g\" | sed \"s/\\]/\\)/g\" | grep -Eo \"[0-9 + -- / * ^ . a-z A-Z ~ : ( ) ]*\") # only grepping valid characters\n  if [ \"$parsedExpression\" != \"$originalEquation\" ];then { echo \"Error: Expression contains invalid characters\"; return 1; }; fi # compare result to original\n  return 0\n}\n\nencodeEquation()\n{\n  equation=$(echo \"$originalEquation\" | sed \"s:/:(over):g\" | sed \"s/~/|/g\" | sed \"s/-/%2D/g\") # encode all the special characters\n}\n\nvalidateOperation()\n{\n  operation=$(echo \"$1\" | tr \"[[:upper:]]\" \"[[:lower:]]\") # get rid of case being an issue\n  validOp=\"false\" # lets us know if oeration is valid\n  for op in \"${simpleOperations[@]}\"; do # go through all valid simple operations\n    if [[ \"$op\" == \"$operation\" ]]; then { opType=\"simple\"; validOp=\"true\"; break; }; fi # if the operation matches leave the loop\n  done\n  if ! $validOp; then { echo \"Error: invalid operation, run newton -h to get a list of valid operations\"; return 1; }; fi # if not a valid operation error out\n  if [[ $operation == \"roots\" ]]; then operation=zeroes;fi # I gave the ability to use root or zeores but real op is zeroes\n}\n\ngetSimpleResponse()\n{\n  result=$(httpGet https://newton.now.sh/api/v2/$operation/\"$equation\" | grep -Eo '\"result\":\"[a-z A-Z 0-9 ( ) \\^ / -- + , ]*' | sed s/'\"result\":\"'//g | tr '\"' \" \") # get reponse, grab result\n  if [[ $result == \"\" ]];then { echo \"Error: no result was returned, did you use valid characters?\"; return 1; }; fi # if result is empty sometthing went wrong...\n}\n\nprintAnswer()\n{\n  cat <<EOF\n================================\n|Operation: $operation\n|Expression: $originalEquation\n|Result: $result\n================================\nEOF\n}\n\n\nusage()\n{\n  cat <<EOF\nNewton\nDescription: Performs numerical calculations all the way up to symbolic math parsing.\nUsage: newton [optionalFlags] [operation] [expression] or newton [flag]\n  -r  Only print the result, useful for piping output elsewhere\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\n ===================================================\n|Operations     Sample Expression      Sample Result|\n|---------------------------------------------------|\n|Simplify       [[2x^2]+7]*[4x^2]    8 x^4 + 28 x^2 |\n|Factor             x^2 + 2x             x (x + 2)  |\n|Derive              x^2+2x               2 x + 2   |\n|Integrate           x^2+2x         1/3 x^3 + x^2 +C|\n|Roots/Zeroes        x^2+2x                2, 0     |\n|Tangent             2~x^3              12 x + -16  | (Finding tangent line when x=2 for expression x^3)\n|Area               2:4~x^3                 60      | (Finding area under curve from 2 to 4 for expression x^3)\n|Cos                   pi                   -1      |\n|Sin                   pi                    0      |\n|Tan                  pi/4                   1      |\n|ArcCos                 1                    0      |\n|ArcSin                 0                    0      |\n|ArcTan                pi                arcsin(pi) |\n|Abs                   -2                    2      |\n|Log                   2~8                   3      | (Log base 2 of eight)\n ===================================================\nValid Symbols:\n  + add\n  - subtract\n  [ left parenthesis (you must use brackets bash has a bultin for parenthesis)\n  ] right parenthesis (you must use brackets bash has a bultin for parenthesis)\n  * multiply\n  / divide\n  ^ power\n  : between the range of left and right side (only for area under curve)\n  ~ parameter on right side (only for area, tangent line and log)\nEOF\n}\n\n\ngetConfiguredClient || exit 1\n\nwhile getopts \"ur:vh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  update\n        exit 0\n        ;;\n    r)  resultOnly=\"true\" && flagCount=$((flagCount + 1 ));;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $# == \"0\" ]]; then usage && exit 0\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"update\" ]]; then checkInternet && update && exit 0 || exit 1\n  elif [[ $1 == \"help\" ]]; then usage && exit 0 || exit 1\n  else echo \"Error: newton needs two arguments, operation and expression\" && exit 1;fi\nelif [ $# -gt 3 ];then echo \"Error: newton only accepts two arguments, operation and expression\" && exit 1;fi\n\n# flagCount helps us determine what argument to pass to the functions\n# flow: validateOperation, validateExpression, encodeEquation, getResponse, print Answer/Result\ncheckInternet || exit 1\nif [[ $flagCount == \"0\" ]];then validateOperation \"$1\" || exit 1\nelif [[ $flagCount == \"1\" ]];then validateOperation \"$2\" || exit 1; fi\nif [[ $flagCount == \"0\" ]];then validateExpression \"$2\" || exit 1\nelif [[ $flagCount == \"1\" ]];then validateExpression \"$3\" || exit 1; fi\nencodeEquation || exit 1\nif [[ $opType == \"simple\" ]];then getSimpleResponse || exit 1;fi\nif [ -z $resultOnly ];then printAnswer\nelse echo \"$result\"; fi\n"
  },
  {
    "path": "pwned/pwned",
    "content": "#!/usr/bin/env bash\n# Author: Navan Chauhan https://github.com/navanchauhan\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nconfiguredPython=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ngetConfiguredPython()\n{\n  if command -v python3 &>/dev/null; then\n    configuredPython=\"python3\"\n  elif  command -v python2 &>/dev/null; then\n    configuredPython=\"python2\"\n  elif command -v python &>/dev/null; then\n    configuredPython=\"python\"\n  else\n    echo \"Error: This tool requires python to be installed.\"\n    return 1\n  fi\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then\n  python()\n  {\n    case \"$configuredPython\" in\n      python2) python2 \"$@\" ;;\n      python)  python \"$@\" ;;\n    esac\n  }\nfi\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n## This function grabs data from Have I been Pwned ? and using python parses it\n## JSON response to extrapolate the information for storage\ngetPwned()\n{\n\tinfo=$(httpGet  \"https://haveibeenpwned.com/api/v2/breachedaccount/$1\") > /dev/null #grab the JSON response\n  export PYTHONIOENCODING=utf8 #necessary for python in some cases\n  echo \"$info\" | python -c \"from __future__ import print_function; import sys, json; print(sys.stdin)[0]['Title'])\" > /dev/null 2>&1 || { echo \"Looks like you have not been breached\"; exit 1; } #\n  # The rest of the code is just extrapolating the data with python from the JSON response\n  echo \"$info\" > .pwned.json\n  title=$(python -c \"from __future__ import print_function; import sys, json; print('\\n'.join([u['Title']for u in json.load(open(sys.argv[1]))]))\" \".pwned.json\")\n  rm -f .pwned.json\n  unset info # done with the JSON response not needed anymore\n}\n\nprintPwned()\n{\n  echo\n  echo \"=============================================\"\n  echo \"$1 has beeen breached at:\"\n  echo \"$title\"\n  echo \"=============================================\"\n  echo\n}\n\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nusage()\n{\n  cat <<EOF\npwned\nDescription: Tells you when your account was last breached\nUsage: pwned [flag] or pwned [tag]\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  pwned navanchauhan@gmail.com\n  pwned navanchauhan@yahoo.com\nEOF\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then getConfiguredPython || exit 1; fi\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $1 == \"update\" ]]; then\n  checkInternet || exit 1\n  update\n  exit 0\nelif [[ $1 == \"help\" ]]; then\n  usage\n  exit 0\nelif [[ $# == \"0\" ]]; then\n  usage\n  exit 0\nelse\n  checkInternet || exit 1\n  getPwned \"$1\" # based on the stock symbol exrapolated by the getTicker function get information on the stock\n  printPwned \"$1\"  # print this information out to the user in a human readable format\nexit 0\nfi\n"
  },
  {
    "path": "qrify/qrify",
    "content": "#!/usr/bin/env bash\n# Author: Linyos Torovoltos github.com/linyostorovovoltos\n\ncurrentVersion=\"1.23.0\"\nmultiline=\"0\" # flag that indicates multiline option\nfileoutput=\"0\" # flag indicating the -f option\n\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ngetConfiguredPython()\n{\n  if command -v python3 &>/dev/null; then\n    configuredPython=\"python3\"\n  elif  command -v python2 &>/dev/null; then\n    configuredPython=\"python2\"\n  elif command -v python &>/dev/null; then\n    configuredPython=\"python\"\n  else\n    echo \"Error: This tool requires python to be installed.\"\n    return 1\n  fi\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then\n  python()\n  {\n    case \"$configuredPython\" in\n      python3) python3 \"$@\" ;;\n      python2) python2 \"$@\" ;;\n      python)  python \"$@\" ;;\n    esac\n  }\nfi\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nmakeqr()\n{\n  input=$(echo \"$input\" | sed s/\" \"/%20/g ) ## replace all spaces in the sentence with HTML-encoded space %20\n  httpGet qrenco.de/\"$input\" ## get a response for the qrcode\n}\n\n# redirects the image obtained from the goqr api into a png file\nmakeQRFile() {\n\tinput=$(echo \"$input\" | sed -e s/\" \"/%20/g -e s/'\\\\n'/%0A/g ) ##same as in the makeqr function\n\n  addFileExt\n\n\thttpGet \"api.qrserver.com/v1/create-qr-code/?size=150x150&data=$input\" > \"$fileName\"\n}\n\naddFileExt() {\n  if ! echo \"$fileName\" | grep -E -q \".*\\.png$|.*\\.PNG$\"\n  then\n    fileName=\"$fileName.png\"\n  fi\n}\n\nmakeMultiLineQr()\n{\n  if [[ ${configuredClient} != \"curl\" ]]; then ## prevent usage without curl it is unreliable\n    echo \"Multiline currently only supports curl!\"\n    return 1\n  else\n    input=$(echo \"$input\" | sed -e s/\" \"/%20/g -e s/'\\\\n'/%0A/g ) ##same as in the makeqr function\n    printf \"%s\" \"$input\"  | curl -F-=\\<- qrenco.de\n  fi\n}\n\n# Function to get the json response from POST request\ndecodeQR() {\n  local qrFile=\"$1\"\n  if ! echo \"$fileName\" | grep -E -q \".*\\.png$|.*\\.PNG$|.*\\.gif$|.*\\.jpg$|.*\\.jpeg$|.*\\.GIF$|.*\\.JPG$|.*\\.JPEG$\"\n  then\n    exit 1\n  fi\n\n  # only uses curl\n  # Cannot use wget because it does not support multipart/form-data (as per the man page)]\n\n  case \"$configuredClient\" in\n    curl) JSONresponse=$(curl -s -F \"file=@$qrFile\" http://api.qrserver.com/v1/read-qr-code/) || exit 1;;\n    wget) echo \"Error:-Not supported with wget\" >&2 && exit 1;;\n    httpie) JSONresponse=$(http -b --form POST http://api.qrserver.com/v1/read-qr-code/ file@\"$qrFile\") || exit 1;;\n    fetch) echo \"Error:-Not supported with wget\" >&2 && exit 1;;\n  esac\n\n  error=\"$(echo \"$JSONresponse\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)[0]['symbol'][0]['error'])\")\"\n  \n  if [[ \"$error\" == \"None\" ]]\n  then\n    data=\"$(echo \"$JSONresponse\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)[0]['symbol'][0]['data'])\")\"\n  else\n    echo \"Error:-$error\" >&2 && exit 1\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nusage()\n{\n  cat <<EOF\nQrify\nDescription: Converts strings or URLs into a QR code.\nUsage: qrify [stringtoturnintoqrcode]\n    -u  Update Bash-Snippet Tools\n    -m  Enable multiline support (feature not working yet)\n    -h  Show the help\n    -v  Get the tool version\n    -f  Store the QR code as a PNG file\n    -d  Decode the QR code from a PNG/GIF/JP(E)G file\nExamples:\n    qrify this is a test string\n    qrify -m two\\\\\\\\nlines\n    qrify github.com (no http:// or https://)\n    qrify -f fileoutputName google.com\n    qrify -d fileName.png\n\n\u001b[31mPlease pay attention:\u001b[0m\nThis script needs access to an external API.\n\u001b[5m\u001b[1mDo not use it to encode sensitive data.\u001b[0m\nEOF\n}\n\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"d:f:m:hvu*:\" option\ndo\n  case \"${option}\" in\n    v) echo \"Version $currentVersion\" && exit 0 ;;\n    u) checkInternet && update && exit 0 || exit 1 ;;\n    h) usage && exit 0 ;;\n    m) multiline=\"1\" && echo \"Error this is not a supported feature yet\" && exit 1 ;;\n\t\tf)\n\t\t\tfileName=$OPTARG\n\t\t\t#file name is the first argument of the option -f\n\t\t\tfileoutput=\"1\";;\n    d)\n      fileName=$OPTARG\n      decode=\"1\";;\n  esac\ndone\n\nif [[ $# == \"0\" ]]; then\n  usage\n  exit 0\nelif [[ $# == \"1\" ]];then\n  if [[ $1 == \"help\" || $1 == \":help\" ]]; then\n    usage\n    exit 0\n  elif [[ $1 == \"update\" ]]; then\n    checkInternet || exit 1\n    update || exit 1\n    exit 0\n  else\n    getConfiguredPython || exit 1\n\tcheckInternet || exit 1\n    input=$(printf '%s ' \"$@\")\n    makeqr || exit 1\n    exit 0\n  fi\nelse\n  getConfiguredPython || exit 1\n  checkInternet || exit 1\n  if [[ $fileoutput == \"1\" ]]\n\tthen\n\t\tinput=$(printf '%s ' \"${@:3}\") # first arg is -f, second is the file name, third onwards is the rest of the argument\n\t\t# will have to be changed when implementing multiline QR code\n\t\tmakeQRFile || exit 1\n\t\texit 0\n  elif [[ $decode == \"1\" ]]\n  then\n    ( decodeQR \"$fileName\" && echo \"$data\" ) || exit 1\n    exit 0\n  elif [[ $multiline == \"0\" ]]; then\n    input=$(printf '%s ' \"$@\")\n    makeqr || exit 1\n    exit 0\n  else\n    input=$(printf '%s ' \"${@:2}\")\n    makeMultiLineQr || exit 1 ## if multiline that means a flag existed so start from the second argument\n    exit 0\n  fi\nfi\n"
  },
  {
    "path": "short/short",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nconfiguredPython=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nusage()\n{\n  cat <<EOF\nShort\nDescription: Shorten urls and unmask shortended urls.\nUsage: short [flag] [URL] or short [flag]\n  -s  Shorten the URL\n  -e  Expand a shortened URL\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExample:\n   Input:  short tinyurl.com/jhkj\n   Output: http://possiblemaliciouswebsiteornot.com\nEOF\n}\n\nexpandURL()\n{\n  testURL=$( echo \"$1\" | cut -c1-8 )\n  if [[ $testURL != \"https://\" ]]; then\n    testURL=$( echo \"$1\" | cut -c1-7 )\n    if [[ $testURL != \"http://\" ]]; then\n      url=\"http://$1\"\n    else\n      url=$1\n    fi\n  else\n    url=$1\n  fi\n  response=$(httpGet https://unshorten.me/s/\"$url\")\n  errorCheck=$(echo \"$response\")\n  if [[ $errorCheck == \"Invalid Short URL\" ]]; then\n  echo \"Error: 404 could not find the website\"\n  return 1\nfi\n  returnedURL=$(echo \"$response\")\n}\n\nshortenURL()\n{\nnewURL=$1\nif [[ $(echo \"$1\" | grep -Eo \"^[h]ttp[s]?://\") == \"\" ]]; then newURL=\"http://\"$1; fi\nresponse=$(httpGet http://tinyurl.com/api-create.php?url=\"$newURL\")\nreturnedURL=$(echo \"$response\")\n}\n\nprintResults()\n{\n  cat <<EOF\n=====================================================================\nShort URL:    $inputURL\nExpanded URL: $returnedURL\n=====================================================================\nEOF\n}\n\nprintShortenedResults()\n{\n  cat <<EOF\n=====================================================================\nOriginal URL:  $newURL\nShortened URL: $returnedURL\n=====================================================================\nEOF\n}\n\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"e:s:uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    e)\n        expand=\"true\"\n        inputURL=$OPTARG\n        ;;\n    s)\n        shorten=\"true\"\n        inputURL=$OPTARG\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif  [[ $expand == \"true\" && $shorten == \"true\" ]];then\n  echo \"Error: the -e and the -s options are mutually exclusive\" >&2\n  exit 1\nfi\n\nif [[ $# == 0 ]]; then\n  usage\n  exit 0\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"update\" ]]; then\n    checkInternet || exit 1\n    update\n  elif [[ $1 == \"help\" ]]; then\n    usage\n\n  else\n    usage\n    exit 1\n  fi\nelif [[ $expand == \"true\" ]];then\n  checkInternet || exit 1\n  expandURL \"$inputURL\" || exit 1\n  printResults\nelif [[ $shorten == \"true\" ]];then\n  if [[ $configuredClient != \"curl\" ]];then\n    echo \"Error: to shorten URLS you must have curl installed\"\n  fi\n  checkInternet || exit 1\n  shortenURL \"$inputURL\"\n  printShortenedResults\nelse\n  echo \"Error: short only accepts one argument\"\n  exit 1\nfi\n"
  },
  {
    "path": "siteciphers/siteciphers",
    "content": "#!/usr/bin/env bash\nDELAY=1\nconfiguredClient=\"\"\ncurrentVersion=\"1.23.0\"\n\ncheckOpenSSL()\n{\n  if  ! command -v openssl &>/dev/null; then\n    echo \"Error: to use this tool openssl must be installed\" >&2\n    return 1\n  else\n    return 0\n  fi\n}\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nusage()\n{\n  cat <<EOF\nSiteciphers\nDescription: Checks the available ciphers for the SSL of an https site.\nUsage: siteciphers [flag] or siteciphers [optionalDFlag] [website]\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\n  -d  Set the delay between requests sent to the site (default is 1 sec)\nExamples:\n  siteciphers github.com\n  siteciphers -d 0.5 github.com\nEOF\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\ncheckCiphers()\n{\n  ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g') # grab all ciphers\n  SERVER=$1:443 # setup the connection server\n  for cipher in ${ciphers[*]}; do # for all possible ciphers\n    result=$(echo | openssl s_client -cipher \"$cipher\" -connect \"$SERVER\" 2>&1)\n    if [[ \"$result\" =~ \":error:\" ]]; then\n      if [[ -z $2 ]]; then\n        error=$(echo -n \"$result\" | cut -d':' -f6)\n        echo \"$cipher - NO ($error)\"\n      fi\n    else\n      if [[ \"$result\" =~ \"Cipher is $cipher\" || \"$result\" =~ \"Cipher    :\" ]]; then\n        echo \"$cipher - YES\"\n      else\n        if [[ -z $2 ]]; then\n          echo \"$cipher - UNKNOWN RESPONSE - $result\"\n        fi\n      fi\n    fi\n    sleep $DELAY # sleep as to not overload the requests to the server\n  done\n}\n\ncheckOpenSSL || exit 1\ngetConfiguredClient || exit 1\n\n\nif [[ $# == \"0\" ]]; then\n  usage\n  exit 1\nelif [[ $1 == \"update\" ]]; then\n  checkInternet || exit 1\n  update\n  exit 0\nelif [[ $1 == \"help\" ]]; then\n  usage\n  exit 0\nfi\n\nwhile getopts \"huvd:\" opt; do ## alows for using options in bash\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    d)  #set the delay with the -d option\n        DELAY=$OPTARG\n        dFlag=\"1\"\n        ;;\n    u)  checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    :)  ## will run when no arguments are provided to to d options\n        echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\ncheckInternet || exit 1\nif [[ $dFlag == \"1\" ]]; then\n  checkCiphers \"$3\" || exit 1 # if dflag is present input will look like siteciphers -d 0.5 github.com making the website the third arg\nelse\n  checkCiphers \"$1\" || exit 1\nfi\n"
  },
  {
    "path": "skeleton",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n# The python and JSON functions can be deleted if the script does not need them\n\n## This function determines which version of python is installed on the machine\ngetConfiguredPython()\n{\n  if command -v python3 &>/dev/null; then\n    configuredPython=\"python3\"\n  elif  command -v python2 &>/dev/null; then\n    configuredPython=\"python2\"\n  elif command -v python &>/dev/null; then\n    configuredPython=\"python\"\n  else\n    echo \"Error: This tool requires python to be installed.\"\n    return 1\n  fi\n}\n\n## Don't alter the python call if it's coming from a Mac\nif [[ $(uname) != \"Darwin\" ]]; then\n  python()\n  {\n    case \"$configuredPython\" in\n      python3) python3 \"$@\" ;;\n      python2) python2 \"$@\" ;;\n      python)  python \"$@\" ;;\n    esac\n  }\nfi\n\n## Grabs an element from a a json string and then echoes it to stdout\n## $1 = the JSON string\n## $n+1 = the elements to be indexed\nAccessJsonElement() {\n  json=\"$1\"\n  shift\n  accessor=\"\"\n  for element in \"$@\"; do\n      accessor=\"${accessor}['$element']\"\n  done\n  echo \"$json\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)${accessor})\"\n  return \"$?\"\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 1.2.0\n  # To test the tool enter in the default values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        git clone \"https://github.com/$githubUserName/$repositoryName\" || { echo \"Couldn't download latest version\"; exit 1; }\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nusage()\n{\n  cat <<EOF\nSkeleton\nDescription: Short desciption of the tool.\nUsage: tool [flags] or tool [flags] [arguments]\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n   tool\n   tool\nEOF\n}\n\n\n\nwhile getopts \"uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  getConfiguredClient || exit 1\n        checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\n# special set of first arguments that have a specific behavior across tools\nif [[ $# == \"0\" ]]; then\n  usage ## if calling the tool with no flags and args chances are you want to return usage\n  exit 0\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"update\" ]]; then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    update || exit 1\n    exit 0\n  elif [[ $1 == \"help\" ]]; then\n    usage\n    exit 0\n  fi\nfi\n\n## The rest of the conditions and code would go here\n## Make sure to use checkInternet at least once before any time httpGet will be called.\n## Make sure to call getConfiguredClient at least once before ever calling checkInternet.\n## Make sure to call getConfiguredPython at least once before trying to pipeout to python directly or using AccessJsonElement"
  },
  {
    "path": "skeleton.bats",
    "content": "#!/usr/bin/env bats\n\nexport TOOL_NAME='skeleton'\n\nsetup() {\n  # $REPO_DIR/tests/skeleton.bats\n  REPO_DIR=\"$( cd \"$( dirname \"${BATS_TEST_DIRNAME}\")\" >/dev/null 2>&1 && pwd)\"\n  TOOL_DIR=\"$( cd \"${REPO_DIR}/${TOOL_NAME}\" >/dev/null 2>&1 && pwd)\"\n}\n\n@test \"Testing ${TOOL_NAME} tool\" {\n  echo \"${TOOL_NAME}\"\n}\n\n@test \"Confirm the \\$REPO_DIR variable is evaluated\" {\n  cd \"${REPO_DIR}\" && pwd\n  [[ \"$status\" -eq 0 ]]\n}\n\n@test \"Change into the tool directory for ${TOOL_NAME}\" {\n  cd \"${TOOL_DIR}\" && pwd\n  [[ \"$status\" -eq 0 ]]\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]]; then\n    run \"${TOOL_DIR}/${TOOL_NAME}\" update\n    [[ \"$status\" -eq 0 ]]\n    [ \"$output\" == \"Bash-Snippets is already the latest version\" ]\n  fi\n}\n\n@test \"The -h option should print usage\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -h\n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"No arguments prints usage instructions\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\"\n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"Get the tools version with -v\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -v\n  [[ \"$status\" -eq 0 ]]\n  expected='Version'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n\n# Tool specific tests\n@test \"Do that cool thing\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" cool\n  [[ \"$status\" -eq 0 ]]\n  expected='This is awesome'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n@test \"Testing coolness factor\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" cool --even-cooler\n  [[ \"$status\" -eq 0 ]]\n  expected='subzero'\n  [[ \"printf '%s\\n' ${lines[1]}\" =~ \"${expected}\" ]]\n}\n\n"
  },
  {
    "path": "stocks/stocks",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n# Author: Navan Chauhan https://github.com/navanchauhan\n# Author: Tyler Stubenvoll https://github.com/tjstub\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nconfiguredPython=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ngetConfiguredPython()\n{\n  if command -v python3 &>/dev/null; then\n    configuredPython=\"python3\"\n  elif  command -v python2 &>/dev/null; then\n    configuredPython=\"python2\"\n  elif command -v python &>/dev/null; then\n    configuredPython=\"python\"\n  else\n    echo \"Error: This tool requires python to be installed.\"\n    return 1\n  fi\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then\n  python()\n  {\n    case \"$configuredPython\" in\n      python3) python3 \"$@\" ;;\n      python2) python2 \"$@\" ;;\n      python)  python \"$@\" ;;\n    esac\n  }\nfi\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\n## Grabs an element from a a json string and then echoes it to stdout\n## $1 = the JSON string\n## $n+1 = the elements to be indexed\nAccessJsonElement() {\n  json=\"$1\"\n  shift\n  accessor=\"\"\n  for element in \"$@\"; do\n      accessor=\"${accessor}['$element']\"\n  done\n  echo \"$json\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)${accessor})\"\n  return \"$?\"\n}\n\n## This function grabs information about a stock and prints it for consumption\nprintStockInformation()\n{\n  # this data is updated hourly.\n  stockProfile=\"$(httpGet \"https://financialmodelingprep.com/api/v3/company/profile/${1}\")\" > /dev/null\n  # this is realtime data.\n  stockPrice=\"$(httpGet \"https://financialmodelingprep.com/api/v3/stock/real-time-price/${1}\")\" > /dev/null\n  # necessary for python in some cases\n  export PYTHONIOENCODING=utf8\n  # checking if we get any information back from the server if not \n  # chances are it isnt a valid stock symbol\n  AccessJsonElement \"$stockProfile\" \"profile\" \"companyName\" > /dev/null 2>&1 \\\n    || { echo \"$1: Not a valid stock symbol\"; exit 1; } \n  # The rest of the code is just extrapolating the data with python \n  # from the JSON response\n  name=\"$(AccessJsonElement \"$stockProfile\" \"profile\" \"companyName\")\"\n  exchangeName=\"$(AccessJsonElement \"$stockProfile\" \"profile\" \"exchange\")\"\n  latestPrice=\"$(AccessJsonElement \"$stockPrice\" \"price\")\"\n  range=\"$(AccessJsonElement \"$stockProfile\" \"profile\" \"range\")\"\n  priceChange=\"$(AccessJsonElement \"$stockProfile\" \"profile\" \"changes\")\"\n  priceChangePercentage=\"$(AccessJsonElement \"$stockProfile\" \"profile\" \"changesPercentage\")\"\n  volumeAvg=\"$(AccessJsonElement \"$stockProfile\" \"profile\" \"volAvg\")\"\n\n  cat <<EOF\n\n==============================================\n| $name -- Stock Information\n==============================================\n| Stock Details\n|   * symbol: $1\n|   * Exchange: $exchangeName\n| Real time data\n|   * Latest Price: $latestPrice\n| Hourly data\n|   * 52 week range: $range\n|   * Price Change: $priceChange\n|   * PriceChangePercent: $priceChangePercentage\n|   * Volume average: $volumeAvg\n==============================================\nEOF\n\n}\n\n## This function queries yahoo to determine the stock ticker for a certain company\n## this allows the usage of stocks to be extended where now you can enter stocks appple\n## and it will determine the stock symbol for apple is AAPL and move on from there\ngetTicker()\n{\n  input=\"$(echo \"$@\" | tr \" \" +)\"\n  response=\"$(httpGet \"http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=$input&region=1&lang=en%22\")\" > /dev/null\n  # using python to extrapolate the stock symbol\n  symbol=\"$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['ResultSet']['Result'][0]['symbol'])\")\"\n  # just unsets the entire response after using it since all I need is the stock ticker\n  unset response \n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nusage()\n{\n  cat <<EOF\nStocks\nDescription: Finds the latest information on a certain stock.\nUsage: stocks [flag] or stocks [company/ticker]\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  stocks AAPL\n  stocks Tesla\nEOF\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then getConfiguredPython || exit 1; fi\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $1 == \"update\" ]]; then\n  checkInternet || exit 1\n  update\n  exit 0\nelif [[ $1 == \"help\" ]]; then\n  usage\n  exit 0\nelif [[ $# == \"0\" ]]; then\n  usage\n  exit 0\nelse\n  checkInternet || exit 1\n  # the company name might have spaces so passing in all args allows for this\n  getTicker \"$@\"\n  # based on the stock symbol exrapolated by the getTicker function get \n  # information on the stock\n  printStockInformation \"$symbol\"\n  exit 0\nfi\n\n"
  },
  {
    "path": "taste/taste",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\nconfiguredPython=\"\"\nsource ~/.bash_profile 2> /dev/null ## allows grabbing enviornment variable\napiKey=$TASTE_API_KEY\ninfo=\"0\" ## indicates if we want extra info\nsearch=\"0\" ## indivates that we want results on the item itself\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ngetConfiguredPython()\n{\n  if command -v python3 &>/dev/null; then\n    configuredPython=\"python3\"\n  elif  command -v python2 &>/dev/null; then\n    configuredPython=\"python2\"\n  elif command -v python &>/dev/null; then\n    configuredPython=\"python\"\n  else\n    echo \"Error: This tool requires python to be installed.\"\n    return 1\n  fi\n}\n\nif [[ $(uname) != \"Darwin\" ]]; then\n  python()\n  {\n    case \"$configuredPython\" in\n      python3) python3 \"$@\" ;;\n      python2) python2 \"$@\" ;;\n      python)  python \"$@\" ;;\n    esac\n  }\nfi\n\n## Grabs an element from a a json string and then echoes it to stdout\n## $1 = the JSON string\n## $n+1 = the elements to be indexed\nAccessJsonElement() {\n  json=\"$1\"\n  shift\n  accessor=\"\"\n  for element in \"$@\"; do\n      accessor=\"${accessor}['$element']\"\n  done\n  echo \"$json\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)${accessor})\"\n  return \"$?\"\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\n## This function gets 3 results similar to the item of interest\ngetSimilar()\n{\n  export PYTHONIOENCODING=utf8 #necessary for python in some cases\n  media=$( echo \"$@\" | tr \" \" + )\n  response=$(httpGet \"https://tastedive.com/api/similar?q=$media&k=$apiKey&info=$info\")\n  ## Extrapolate the information by parsing the JSON\n  nameOne=$(echo \"$response\" |python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][0]['Name'])\" 2>  /dev/null || { echo \"Error: Did you search a valid item?\"; return 1; } )\n  typeOne=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][0]['Type'])\" 2>  /dev/null)\n  nameTwo=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][1]['Name'])\" 2>  /dev/null)\n  typeTwo=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][1]['Type'])\" 2>  /dev/null)\n  nameThree=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][2]['Name'])\" 2>  /dev/null)\n  typeThree=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][2]['Type'])\" 2>  /dev/null)\n  if [[ $info == \"1\" ]];then ## if we want more detailed info we have to grab a few more fields\n    wikiOne=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][0]['wTeaser'])\" 2>  /dev/null)\n    wikiTwo=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][1]['wTeaser'])\" 2>  /dev/null)\n    wikiThree=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][2]['wTeaser'])\" 2>  /dev/null)\n    youtube=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Results'][0]['yUrl'])\" 2>  /dev/null)\n  fi\n}\n\n## This function grabs all the information it can on the item of interest itself\ngetInfo()\n{\n  export PYTHONIOENCODING=utf8 #necessary for python in some cases\n  media=$( echo \"$@\" | tr \" \" + )\n  response=$(httpGet \"https://tastedive.com/api/similar?q=$media&k=$apiKey&info=$info\")\n  name=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Info'][0]['Name'])\")\n  type=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Info'][0]['Type'])\")\n  if [[ $info == \"1\" ]]; then\n    wiki=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Info'][0]['wTeaser'])\")\n    youtube=$(echo \"$response\" | python -c \"from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['Similar']['Info'][0]['yUrl'])\")\n  else\n    wiki=\"None\"\n    youtube=\"None\"\n  fi\n}\n\nprintResults()\n{\n  if [[ $info == \"1\" ]];then\n    echo \"===================================\"\n    echo\n    echo \"$nameOne\": \"$typeOne\"\n    echo \"$wikiOne\"\n    echo\n    echo\n    echo \"$nameTwo\": \"$typeTwo\"\n    echo \"$wikiTwo\"\n    echo\n    echo\n    echo \"$nameThree\": \"$typeThree\"\n    echo \"$wikiThree\"\n    echo\n    if [[ $youtube != \"None\" ]]; then echo $youtube; fi\n    echo\n    echo \"===================================\"\n  else\n    echo \"===================================\"\n    echo \"$nameOne\": \"$typeOne\"\n    echo \"$nameTwo\": \"$typeTwo\"\n    echo \"$nameThree\": \"$typeThree\"\n    echo \"===================================\"\n  fi\n}\n\nprintInfo()\n{\n  echo \"===================================\"\n  echo\n  echo \"$name\": \"$type\"\n  echo $wiki\n  echo\n  if [[ $youtube != \"None\" ]]; then echo $youtube; fi\n  echo \"===================================\"\n}\n\nusage()\n{\n  cat <<EOF\nTaste\nDescription: A recommendation engine that provides 3 similar items based on some input topic.\n  Taste also has the ability to provide information on the item of interest.\n  Supports: shows, books, music, artists, movies, authors, games\nUsage: taste [flag] [item]\n  -i  Get more information on similar items\n  -s  Get information on the item itself\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  taste -i Kendrick Lamar\n  taste Catcher in the Rye\n  taste -s Red Hot Chili Peppers\nEOF\n}\n\nif [[ $apiKey == \"\" ]]; then\n  cat <<EOF\nError: API key not setup properly\nTo get an API key visit https://tastedive.com/account/api_access\nAfter getting the API key run the following command: export TASTE_API_KEY=\"yourAPIKeyGoesHere\"\nAfter following all the steps and issues still persist try adding export TASTE_API_KEY manually to your .bash_profile\nEOF\n  exit 1\nfi\nif [[ $(uname) != \"Darwin\" ]]; then getConfiguredPython || exit 1; fi\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"uvhis\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    i)  if [[ $search == \"0\" ]]; then\n          info=\"1\"\n        else\n          echo \"Error: the options -i and -s are mutually exclusive (-s already uses -i)\"\n          exit 1\n        fi\n        ;;\n    s)  if [[ $info != \"1\" ]]; then\n          search=\"1\"\n          info=\"1\"\n        else\n          echo \"Error: the options -i and -s are mutually exclusive (-s already uses -i)\"\n          exit 1\n        fi\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $# == 0 ]]; then\n  usage\nelif [[ $1 == \"update\" ]]; then\n  checkInternet || exit 1\n  update\nelif [[ $1 == \"help\" ]]; then\n  usage\nelse\n  checkInternet || exit 1\n  if [[ $search == \"0\" ]]; then\n    if [[ $info == \"0\" ]]; then\n      getSimilar \"$@\" || exit 1 ## exit if we return 1 (chances are movie was not found)\n      printResults\n    else\n      getSimilar \"${@:2}\" || exit 1\n      printResults\n    fi\n  else\n    getInfo \"${@:2}\" || exit 1 ## exit if we return 1 (chances are movie was not found)\n    printInfo\n  fi\nfi\n"
  },
  {
    "path": "tests/bak2dvd.bats",
    "content": "#!/usr/bin/env bats\n#\nexport TOOL_NAME='bak2dvd'\n\nsetup() {\n  # $REPO_DIR/tests/bak2dvd.bats\n  REPO_DIR=\"$( cd \"$( dirname \"${BATS_TEST_DIRNAME}\")\" >/dev/null 2>&1 && pwd)\"\n  TOOL_DIR=\"$( cd \"${REPO_DIR}/${TOOL_NAME}\" >/dev/null 2>&1 && pwd)\"\n}\n\n@test \"Testing ${TOOL_NAME} tool\" {\n  echo \"${TOOL_NAME}\"\n}\n\n@test \"Confirm the \\$REPO_DIR variable is evaluated\" {\n  cd \"${REPO_DIR}\" && pwd\n  \n  [[ \"$status\" -eq 0 ]]\n}\n\n# can cd into script dir\n@test \"Confirm a valid directory for ${TOOL_NAME}\" {\n  cd \"${TOOL_DIR}\" && pwd\n  \n  [[ \"$status\" -eq 0 ]]\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]]; then\n    run \"${TOOL_DIR}/${TOOL_NAME}\" update\n  \n    [[ \"$status\" -eq 0 ]]\n    [ \"$output\" == \"Bash-Snippets is already the latest version\" ]\n  fi\n}\n\n@test \"The -h option should print usage\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -h\n  \n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"No arguments prints usage instructions\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\"\n  \n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"Get the tools version with -v\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -v\n  \n  [[ \"$status\" -eq 0 ]]\n  expected='Version'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n# Tool specific tests\n\n"
  },
  {
    "path": "tests/cheat.bats",
    "content": "#!/usr/bin/env bats\n\nexport TOOL_NAME='cheat'\n\nsetup() {\n  # $REPO_DIR/tests/tool.bats\n  REPO_DIR=\"$( cd \"$( dirname \"${BATS_TEST_DIRNAME}\")\" >/dev/null 2>&1 && pwd)\"\n  TOOL_DIR=\"$( cd \"${REPO_DIR}/${TOOL_NAME}\" >/dev/null 2>&1 && pwd)\"\n}\n\n@test \"Testing ${TOOL_NAME} tool\" {\n  echo \"${TOOL_NAME}\"\n}\n\n@test \"Confirm the \\$REPO_DIR variable is evaluated\" {\n  cd \"${REPO_DIR}\" && pwd\n  \n  [[ \"$status\" -eq 0 ]]\n}\n\n# can cd into script dir\n@test \"Confirm a valid directory for ${TOOL_NAME}\" {\n  cd \"${TOOL_DIR}\" && pwd\n  \n  [[ \"$status\" -eq 0 ]]\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]]; then\n    run \"${TOOL_DIR}/${TOOL_NAME}\" update\n  \n    [[ \"$status\" -eq 0 ]]\n    [ \"$output\" == \"Bash-Snippets is already the latest version\" ]\n  fi\n}\n\n@test \"The -h option should print usage\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -h\n  \n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"No arguments prints usage instructions\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\"\n  \n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"Get the tools version with -v\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -v\n  \n  [[ \"$status\" -eq 0 ]]\n  expected='Version'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n@test \"Grabbing information on a programming language (rust)\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" rust\n  [[ \"$status\" -eq 0 ]]\n  [[ \"${lines[0]}\" =~ 'Rust is a systems' ]]\n}\n\n@test \"Testing unkown topic due to misspelling\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" suuuper thiingsa\n  [[ \"$status\" -eq 0 ]]\n  [[ \"printf '%s\\n' ${lines[1]}\" =~ 'Unknown' ]]\n}\n"
  },
  {
    "path": "tests/cloudup.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing cloudup tool\" {\n   echo cloudup\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run cloudup update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run cloudup -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Cloudup\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  run cloudup -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(cloudup -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/crypt.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing crypt tool\" {\n   echo crypt\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run crypt update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run crypt -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Crypt\" ]\n}\n\n@test \"No arguments prints usage instructions\" {\n  run crypt\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Crypt\" ]\n}\n\n\n@test \"Get the tools version with -v\" {\n  run crypt -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(crypt -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/cryptocurrency.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing cryptocurrency tool\" {\n   echo cryptocurrency\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run cryptocurrency update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run cryptocurrency -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"CryptoCurrency\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  run cryptocurrency -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(cryptocurrency -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/currency.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing currency tool\" {\n   echo currency\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run currency update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run currency -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Currency\" ]\n}\n\n@test \"Testing currency exchange (12.35 EUR TO USD)\" {\n  run currency EUR USD 12.35\n  [ \"$status\" -eq 0 ]\n  ##[ \"${lines[0]}\" = \"=========================\" ]\n  ##[ \"${lines[1]}\" = \"| EUR to USD\" ]\n  ##[ \"${lines[3]}\" = \"| EUR: 12.35\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  run currency -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(currency -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/geo.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing geo tool\" {\n   echo geo\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run geo update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run geo -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Geo\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  run geo -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(geo -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/gist.bats",
    "content": "#!/usr/bin/env bats\n\nexport TOOL_NAME='gist'\nexport GIST_USER='phamhsieh'\nexport GIST_API_TOKEN='dd43dc9949a5b4a1d6c7''b779f13af357282016e4'\n\nsetup() {\n  # $REPO_DIR/tests/taste.bats\n  REPO_DIR=\"$( cd \"$( dirname \"${BATS_TEST_DIRNAME}\")\" >/dev/null 2>&1 && pwd)\"\n  TOOL_DIR=\"$( cd \"${REPO_DIR}/${TOOL_NAME}\" >/dev/null 2>&1 && pwd)\"\n}\n\n@test \"Testing ${TOOL_NAME} tool\" {\n  echo \"${TOOL_NAME}\"\n}\n\n@test \"Get the tools version with command version\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" version\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(${TOOL_DIR}/${TOOL_NAME} version) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]]; then\n    run \"${TOOL_DIR}/${TOOL_NAME}\" update\n\n    [[ \"$status\" -eq 0 ]]\n    [ \"$output\" == \"Bash-Snippets is already the latest version\" ]\n  fi\n}\n\n@test \"The help command should print usage\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" help\n\n  [[ \"$status\" -eq 0 ]]\n  [[ \"${lines[0]}\" = \"${TOOL_NAME}\" ]]\n}\n\n@test \"Use config command to add configuarion for user\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" config user ${GIST_USER}\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[-1]}\" = \"user=${GIST_USER}\" ]\n}\n\n@test \"Use config command to add configuarion for token\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" config token ${GIST_API_TOKEN}\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[-1]}\" = \"token=${GIST_API_TOKEN}\" ]\n}\n\n@test \"The new command should create a new public gist with gist command\" {\n  hint=false run \"${TOOL_DIR}/${TOOL_NAME}\" new --file gist --desc 'Manage gist like a pro' \"${TOOL_DIR}/${TOOL_NAME}\"\n  [ \"$status\" -eq 0 ]\n  [[ \"${lines[-1]}\" =~ ([0-9]+ +https://gist.github.com/[0-9a-z]+) ]]\n}\n\n@test \"The fetch command should fetch user gists\" {\n  hint=false run \"${TOOL_DIR}/${TOOL_NAME}\" fetch\n  [ \"$status\" -eq 0 ]\n  [[ \"${lines[-1]}\" =~ ([0-9]+ +https://gist.github.com/[0-9a-z]+) ]]\n}\n\n@test \"The fetch command should fetch starred gists\" {\n  hint=false run \"${TOOL_DIR}/${TOOL_NAME}\" fetch star\n  [ \"$status\" -eq 0 ]\n  echo ${lines[-1]}\n  [[ \"${lines[-1]}\" =~ (Not a single valid gist|^ *s[0-9]+ +https://gist.github.com/[0-9a-z]+) ]]\n}\n\n@test \"No arguments prints the list of gists\" {\n  hint=false run \"${TOOL_DIR}/${TOOL_NAME}\"\n  [ \"$status\" -eq 0 ]\n  [[ \"${lines[-1]}\" =~ ([0-9]+ +https://gist.github.com/[0-9a-z]+) ]]\n}\n\n@test \"Specify an index to return the path of cloned repo\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" 1 --no-action\n  [ \"$status\" -eq 0 ]\n  [[ \"${lines[-1]}\" =~ (${HOME}/gist/[0-9a-z]+) ]]\n}\n\n@test \"The edit command should modify the description of a gist\" {\n  \"${TOOL_DIR}/${TOOL_NAME}\" edit 1 \"Modified description\"\n  run \"${TOOL_DIR}/${TOOL_NAME}\" detail 1\n  [ \"$status\" -eq 0 ]\n  [[ \"${lines[0]}\" =~ (Modified description$) ]]\n}\n\n@test \"The delete command should delete specified gists\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" delete 1 --force\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = '1 deleted' ]\n}\n\n@test \"The user command should get the list of public gists from a user\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" user defunkt\n  [ \"$status\" -eq 0 ]\n  [[ \"${lines[0]}\" =~ (https://gist.github.com/[0-9a-z]+ defunkt) ]]\n}\n"
  },
  {
    "path": "tests/meme.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing meme tool\" {\n   echo meme\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run meme update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run meme -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Meme\" ]\n}\n\n\n\n@test \"Get the tools version with -v\" {\n  run meme -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(meme -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/movies.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing movies tool\" {\n   echo movies\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run movies update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run movies -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Movies\" ]\n}\n\n@test \"No arguments prints usage instructions\" {\n  run movies\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Movies\" ]\n}\n\n@test \"Get information on a single movie\" {\n  run movies Argo\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"+=====================================================+\" ]\n  [ \"${lines[1]}\" = \"|      Title: Argo                                    |\" ]\n}\n\n\n\n@test \"Get the tools version with -v\" {\n  run movies -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(movies -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/newton.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing newton tool\" {\n   echo newton\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run newton update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run newton -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Newton\" ]\n}\n\n@test \"Testing newton simplify for [[2x^2]+7]*[4x^2]\" {\n  run newton simplify [[2x^2]+7]*[4x^2]\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"================================\" ]\n  if [ $(uname) == \"Linux\" ];then\n    [ \"${lines[3]}\" = \"|Result: 8 x^4 + 28 x^2\" ] ## this works for darwin but the test wont\n  fi\n}\n\n@test \"Testing newton bad characters in expression \" {\n  run newton simplify 3x=\n  [ \"$status\" -eq 1 ]\n  [ \"${lines[0]}\" = \"Error: Expression contains invalid characters\" ]\n}\n\n@test \"Testing newton bad operation \" {\n  run newton jokes 2x^2\n  [ \"$status\" -eq 1 ]\n  [ \"${lines[0]}\" = \"Error: invalid operation, run newton -h to get a list of valid operations\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  run newton -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(newton -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/qrify.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing qrify tool\" {\n   echo qrify\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run qrify update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run qrify -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Qrify\" ]\n}\n\n@test \"Getting the qr code for a test string\" {\n  run qrify this is a test string\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"█████████████████████████████████\" ]\n  [ \"${lines[1]}\" = \"█████████████████████████████████\" ]\n  [ \"${lines[2]}\" = \"████ ▄▄▄▄▄ ██▀▄████ ██ ▄▄▄▄▄ ████\" ]\n  [ \"${lines[3]}\" = \"████ █   █ █▄▀█▄▀█ ▀▀█ █   █ ████\" ]\n  [ \"${lines[4]}\" = \"████ █▄▄▄█ ██▄▀▀  ▄ ▀█ █▄▄▄█ ████\" ]\n}\n\n\n\n\n\n@test \"No arguments prints usage instructions\" {\n  run qrify\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Qrify\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  run qrify -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(qrify -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/short.bats",
    "content": "#!/usr/bin/env bats\n\nexport TOOL_NAME='short'\n\nsetup() {\n  # $REPO_DIR/tests/short.bats\n  REPO_DIR=\"$( cd \"$( dirname \"${BATS_TEST_DIRNAME}\")\" >/dev/null 2>&1 && pwd)\"\n  TOOL_DIR=\"$( cd \"${REPO_DIR}/${TOOL_NAME}\" >/dev/null 2>&1 && pwd)\"\n}\n\n@test \"Testing ${TOOL_NAME} tool\" {\n  echo \"${TOOL_NAME}\"\n}\n\n@test \"Confirm the \\$REPO_DIR variable is evaluated\" {\n  cd \"${REPO_DIR}\" && pwd\n  \n  [[ \"$status\" -eq 0 ]]\n}\n\n# can cd into script dir\n@test \"Confirm a valid directory for ${TOOL_NAME}\" {\n  cd \"${TOOL_DIR}\" && pwd\n  \n  [[ \"$status\" -eq 0 ]]\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]]; then\n    run \"${TOOL_DIR}/${TOOL_NAME}\" update\n  \n    [[ \"$status\" -eq 0 ]]\n    [ \"$output\" == \"Bash-Snippets is already the latest version\" ]\n  fi\n}\n\n@test \"The -h option should print usage\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -h\n  \n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"No arguments prints usage instructions\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\"\n  \n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"Get the tools version with -v\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -v\n  \n  [[ \"$status\" -eq 0 ]]\n  expected='Version'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n# Tool specific tests\n\n@test \"Shorten github repo URL\" {\n  longurl='https://github.com/alexanderepstein/Bash-Snippets'\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -s \"${longurl}\"\n  \n  [[ \"$status\" -eq 0 ]]\n  expected='http://tinyurl.com/.+'\n  [[ \"${lines[2]}\" =~ (${expected}) ]]\n}\n\n@test \"Expand tinyurl URL\" {\n  shorturl='http://tinyurl.com/uowfbb5'\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -e \"${shorturl}\"\n  \n  [[ \"$status\" -eq 0 ]]\n  expected='https://github.com/alexanderepstein/Bash-Snippets'\n  [[ \"${lines[2]}\" =~ \"${expected}\" ]]\n}\n\n"
  },
  {
    "path": "tests/siteciphers.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing siteciphers tool\" {\n   echo siteciphers\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run siteciphers update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"No arguments prints usage instructions\" {\n  run siteciphers\n  [ \"$status\" -eq 1 ]\n  [ \"${lines[0]}\" = \"Siteciphers\" ]\n}\n\n@test \"The -h option should print usage\" {\n  run siteciphers -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Siteciphers\" ]\n}\n\n#@test \"Running siteciphers on travis-ci\" {\n#  run siteciphers travis-ci.org\n#  [ \"$status\" -eq 0 ]\n#  [ \"${lines[0]}\" = \"ECDHE-RSA-AES256-GCM-SHA384 - NO (tlsv1 alert insufficient security)\" ]\n#}\n\n\n@test \"Get the tools version with -v\" {\n  run siteciphers -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(siteciphers -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/stocks.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing stocks tool\" {\n   echo stocks\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run stocks update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run stocks -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Stocks\" ]\n}\n\n@test \"No arguments prints usage instructions\" {\n  run stocks\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Stocks\" ]\n}\n\n@test \"Get stock info by passing in ticker\" {\n  result=$( echo $(stocks AAPL) | grep -Eo \"Apple Inc. -- Stock Information\" )\n  [ \"$result\" = \"Apple Inc. -- Stock Information\" ]\n\n}\n\n@test \"Get stock info by passing in company\" {\n  result=$( echo $(stocks Apple) | grep -Eo \"Apple Inc. -- Stock Information\" )\n  [ \"$result\" = \"Apple Inc. -- Stock Information\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  run stocks -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(stocks -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/taste.bats",
    "content": "#!/usr/bin/env bats\n\nexport TOOL_NAME='taste'\nexport TASTE_API_KEY=\"290044-Taste-QIQUQKOZ\"\n\nsetup() {\n  # $REPO_DIR/tests/taste.bats\n  REPO_DIR=\"$( cd \"$( dirname \"${BATS_TEST_DIRNAME}\")\" >/dev/null 2>&1 && pwd)\"\n  TOOL_DIR=\"$( cd \"${REPO_DIR}/${TOOL_NAME}\" >/dev/null 2>&1 && pwd)\"\n}\n\n@test \"Testing ${TOOL_NAME} tool\" {\n  echo \"${TOOL_NAME}\"\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]]; then\n    run \"${TOOL_DIR}/${TOOL_NAME}\" update\n\n    [[ \"$status\" -eq 0 ]]\n    [ \"$output\" == \"Bash-Snippets is already the latest version\" ]\n  fi\n}\n\n@test \"The -h option should print usage\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -h\n\n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"No arguments prints usage instructions\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\"\n\n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"Get the tools version with -v\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -v\n\n  [[ \"$status\" -eq 0 ]]\n  expected='Version'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n@test \"Testing short recommendations\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" 50 Cent\n\n  # order of ouput lines changed\n  [[ \"$status\" -eq 0 ]]\n  expected='(G-Unit|The Game|Lloyd Banks): .+'\n  [ \"${lines[0]}\" = \"===================================\" ]\n  [[ \"${lines[1]}\" =~ ${expected} ]]\n  [[ \"${lines[2]}\" =~ ${expected} ]]\n  [[ \"${lines[3]}\" =~ ${expected} ]]\n  [ \"${lines[4]}\" = \"===================================\" ]\n}\n\n@test \"Testing long recommendations\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -i Sublime\n\n  [[ \"$status\" -eq 0 ]]\n  expected='Soundsystem is the fifth studio album by 311, released on October 12, 1999. Soundsystem, which was certified Gold by the RIAA,'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n@test \"Testing search on item\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -s Kendrick Lamar\n\n  [[ \"$status\" -eq 0 ]]\n  expected='Kendrick Lamar Duckworth'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n"
  },
  {
    "path": "tests/todo.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing todo tool\" {\n   echo todo\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run todo update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n\n@test \"No arguments prints usage instructions\" {\n  run todo\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Todo\" ]\n}\n\n@test \"The -h option should print usage\" {\n  run todo -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Todo\" ]\n}\n\n@test \"Adding task\" {\n  run todo -a First task ever\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(todo -g) | grep -Eo \"01\\). First task ever\" )\n  [ \"$result\" = \"01). First task ever\" ]\n}\n\n@test \"Getting task\" {\n  run todo -g\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(todo -g) | grep -Eo \"01\\). First task ever\" )\n  [ \"$result\" = \"01). First task ever\" ]\n}\n\n@test \"Removing task\" {\n  run todo -r \"1\"\n  [ \"$status\" -eq 0 ]\n  result=$( cat ~/.todo/list.txt )\n  echo $result\n  [ \"$result\" = \"\" ]\n}\n\n@test \"Getting from empty task list\" {\n  run todo -g\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"No tasks found\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  run todo -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(todo -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/transfer.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing transfer tool\" {\n   echo transfer\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run transfer update\n  [ \"$status\" -eq 0 ]\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run transfer -h\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Transfer\" ]\n}\n\n@test \"Testing file upload\" {\n  touch $HOME/testFile.txt\n  echo -n \"This is some example content.\" > $HOME/testFile.txt\n  run transfer $HOME/testFile.txt\n  transferResponse=$(transfer $HOME/testFile.txt)\n  rm -f $HOME/testFile.txt\n  transferCommand=$( echo $transferResponse | cut -d $'\\n' -f 3 | sed s/\"Transfer Download Command:\"//g | sed s:\"desiredOutputDirectory\":\"$HOME\":g | sed s:\"^ \"::g)\n  transferStatus=$( echo $transferResponse | grep -Eo \"Success!\")\n  [ \"$status\" -eq 0 ]\n  [ \"$transferStatus\" = \"Success!\" ] ## this works for darwin but the test wont\n}\n\n\n#@test \"Testing file upload & download\" {\n#touch $HOME/testFile.txt\n#echo -n \"This is some example content.\" > $HOME/testFile.txt\n#ransferResponse=$(transfer $HOME/testFile.txt)\n#transferCommand=$( echo $transferResponse | cut -d $'\\n' -f 3 | sed s/\"Transfer Download Command:\"//g | sed s:\"desiredOutputDirectory\":\"$HOME\":g | sed s:\"^ \"::g)\n#id=$(echo $transferResponse | cut -d \"/\" -f 4)\n#transferStatus=$( echo $transferResponse | grep -Eo \"Success!\")\n#[ \"$transferStatus\" = \"Success!\" ]\n#rm -f $HOME/testFile.txt\n#if [ -f  $HOME/testFile.txt ];then exit 1;fi\n#run transfer -d $HOME $id testFile.txt\n#if [ ! -f  $HOME/testFile.txt ];then exit 1;fi\n#contents=$(cat $HOME/testFile.txt)\n#if [ $contents != \"This is some example content.\" ];then exit 1; fi\n#rm -f $HOME/testFile.txt\n#transferResponse=$(transfer -d $HOME $id testFile.txt)\n#transferStatus=$( echo $transferResponse | grep -Eo \"Success!\")\n#[ \"$transferStatus\" = \"Success!\" ]\n#rm -f $HOME/testFile.txt\n#}\n\n@test \"Get the tools version with -v\" {\n  run transfer -v\n  [ \"$status\" -eq 0 ]\n  result=$( echo $(transfer -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "tests/weather.bats",
    "content": "#!/usr/bin/env bats\n\nexport TOOL_NAME='weather'\n\nsetup() {\n  # $REPO_DIR/tests/weather.bats\n  REPO_DIR=\"$( cd \"$( dirname \"${BATS_TEST_DIRNAME}\")\" >/dev/null 2>&1 && pwd)\"\n  TOOL_DIR=\"$( cd \"${REPO_DIR}/${TOOL_NAME}\" >/dev/null 2>&1 && pwd)\"\n}\n\n@test \"Testing ${TOOL_NAME} tool\" {\n  echo \"${TOOL_NAME}\"\n}\n\n@test \"Confirm the \\$REPO_DIR variable is evaluated\" {\n  cd \"${REPO_DIR}\" && pwd\n\n  [[ \"$status\" -eq 0 ]]\n}\n\n# can cd into script dir\n@test \"Confirm a valid directory for ${TOOL_NAME}\" {\n  cd \"${TOOL_DIR}\" && pwd\n\n  [[ \"$status\" -eq 0 ]]\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]]; then\n    run \"${TOOL_DIR}/${TOOL_NAME}\" update\n\n    [[ \"$status\" -eq 0 ]]\n    [ \"$output\" == \"Bash-Snippets is already the latest version\" ]\n  fi\n}\n\n@test \"The -h option should print usage\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -h\n\n  [[ \"$status\" -eq 0 ]]\n  # if bash is less than 7 yrs old\n  if ((${BASH_VERSINFO[0]} >= 4)); then\n    [[ \"${lines[0]}\" = \"${TOOL_NAME^}\" ]]\n  else\n    # or im probably a stoneage mac\n    [[ \"$(echo \"${output}\" | grep -i \"${TOOL_NAME}\")\" ]]\n  fi\n}\n\n@test \"No arguments shows weather at current location\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\"\n\n  [[ \"$status\" -eq 0 ]]\n  expected='Weather report: .+'\n  [[ \"${lines[0]}\" =~ ${expected} ]]\n}\n\n@test \"Get the tools version with -v\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" -v\n\n  [[ \"$status\" -eq 0 ]]\n  expected='Version'\n  [[ \"${output}\" =~ \"${expected}\" ]]\n}\n\n# Tool specific tests\n@test \"Testing weather with specified location\" {\n  run \"${TOOL_DIR}/${TOOL_NAME}\" Paramus\n\n  [ \"$status\" -eq 0 ]\n  # API changed\n  #[ \"${lines[0]}\" = \"Weather report: Paramus, United States of America\" ]\n  [ \"${lines[0]}\" = \"Weather report: Paramus\" ]\n}\n\n"
  },
  {
    "path": "tests/ytview.bats",
    "content": "#!/usr/bin/env bats\n\n@test \"Testing ytview tool\" {\n   echo ytview\n}\n\n@test \"Check for latest version of bash-snippets on update\" {\n  if [[ \"$(uname)\" == \"Linux\" ]];then\n  run ytview update\n  [ \"$output\" = \"Bash-Snippets is already the latest version\" ]\nfi\n}\n\n@test \"The -h option should print usage\" {\n  run ytview -h\n  [ \"${lines[0]}\" = \"Ytview\" ]\n}\n\n@test \"No arguments prints usage instructions\" {\n  run ytview\n  [ \"$status\" -eq 0 ]\n  [ \"${lines[0]}\" = \"Ytview\" ]\n}\n\n@test \"Get the tools version with -v\" {\n  result=$( echo $(ytview -v) | grep -Eo \"Version\")\n  [ \"$result\" = \"Version\" ]\n}\n"
  },
  {
    "path": "todo/todo",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\nflag=\"\"\ncurrentVersion=\"1.23.0\"\nconfiguredClient=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\naddTask()\n{\n  if [ ! -f ~/.todo/list.txt ]; then\n    if [ ! -d ~/.todo ]; then mkdir ~/.todo; fi\n    touch ~/.todo/list.txt\n  fi\n  echo \"$1       ;      $(date)\" >> ~/.todo/list.txt\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nremoveTask()\n{\n  ## Check for valid task numbers (valid characters)\n  if [ -f ~/.todo/temp.txt ];then rm -f ~/.todo/temp.txt;fi\n  touch ~/.todo/temp.txt\n  for taskToRemove in \"$@\";do\n    oldTaskNumber=$taskToRemove\n    taskNumber=$( echo \"$taskToRemove\" | grep -Eo \"[0-9]*\" )\n    if [[ $taskNumber == \"\" || $oldTaskNumber != $taskNumber ]]; then echo \"Error: $oldTaskNumber is not a valid task number!\" && return 1; fi\n  done\n  count=\"0\"\n  IFS=$'\\n'       # make newlines the only separator\n\n  ## Removing the task (only don't add to temp if we should remove it)\n  for task in $(cat ~/.todo/list.txt); do\n    removeIt=\"false\"\n    for taskToRemove in \"$@\";do\n      if [[ $(($count + 1)) == \"$taskToRemove\" ]]; then\n      removeIt=\"true\"\n      break\n      fi\n    done\n    if ! $removeIt ;then echo \"$task\" >> ~/.todo/temp.txt;fi\n    count=$(( $count + 1 ))\n  done\n  rm -f ~/.todo/list.txt\n  cp  ~/.todo/temp.txt ~/.todo/list.txt\n  rm -f ~/.todo/temp.txt\n\n  ##Checking if the task exists\n  for taskToRemove in \"$@\" ;do\n    if [ $count -lt \"$taskToRemove\" ]; then\n      echo \"Error: task number $taskToRemove does not exist!\"\n    else\n      echo \"Sucessfully removed task number $taskToRemove\"\n    fi\n  done\n}\n\ngetTasks()\n{\n  if [ -f ~/.todo/list.txt ]; then\n    checkEmpty=$(cat ~/.todo/list.txt)\n    if [[ $checkEmpty == \"\" ]]; then\n      echo \"No tasks found\"\n    else\n      count=\"1\"\n      IFS=$'\\n'       # make newlines the only separator\n      for task in $(cat ~/.todo/list.txt); do\n        tempTask=$count\n        if [ $count -lt 10 ]; then tempTask=\"0$count\"; fi\n        echo \"$tempTask). $task\"  >> ~/.todo/getTemp.txt\n        count=$(( $count + 1 ))\n      done\n      cat ~/.todo/getTemp.txt | column -t -s \";\"\n      rm -f ~/.todo/getTemp.txt\n    fi\n  else\n    echo \"No tasks found\"\n  fi\n}\n\nusage()\n{\n  cat <<EOF\nTodo\nDescription: A simplistic commandline todo list.\nUsage: todo [flags] or todo [flags] [arguments]\n  -c  Clear all the current tasks\n      Can also use clear instead of -c\n  -r  Remove the following task numbers seprated by spaces\n      Can also use remove instead of -r\n  -g  Get the current tasks\n      Can also use list instead of -g\n  -a  Add the following task\n      Can also use add instead of -a\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n   todo -a My very first task\n   todo remove 2\n   todo -r 1 3\n   todo add Another Task\n   todo list\n   todo -g\n   todo -c\n   todo clear\nEOF\n}\n\nclearAllTasks()\n{\n  rm -f ~/.todo/list.txt || return 1\n  touch ~/.todo/list.txt || return 1\n  echo \"Tasks cleared.\"\n}\n\nwhile getopts \"cr:a:guvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    c)  if [[ $flag == \"\" ]]; then\n          flag=\"clear\"\n        else\n          echo \"Error: all flags are mutually exclusive\"\n          exit 1\n        fi\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    g)  if [[ $flag == \"\" ]]; then\n          flag=\"get\"\n        else\n          echo \"Error: all flags are mutually exclusive\"\n          exit 1\n        fi\n        ;;\n    r)  if [[ $flag == \"\" ]]; then\n          flag=\"remove\"\n        else\n          echo \"Error: all flags are mutually exclusive\"\n          exit 1\n        fi\n        ;;\n    a)  if [[ $flag == \"\" ]]; then\n          flag=\"add\"\n        else\n          echo \"Error: all flags are mutually exclusive\"\n          exit 1\n        fi\n        ;;\n    u)  getConfiguredClient || exit 1\n        checkInternet || exit 1\n        update\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $# == \"0\" ]]; then\n  usage\nelif [[ $# == \"1\" ]]; then\n  if [[ $1 == \"clear\" ]]; then\n    clearAllTasks || exit 1\n  elif [[ $1 == \"update\" ]]; then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    update || exit 1\n    exit 0\n  elif [[ $1 == \"help\" ]]; then\n    usage\n    exit 0\n  elif [[ $flag == \"clear\" || $1 == \"clear\" ]]; then clearAllTasks || exit 1\n  elif [[ $flag == \"get\" || $1 == \"list\" || $1 == \"get\" ]]; then getTasks || exit 1\n  else { echo \"Error: the argument $1 is not valid\"; exit 1; }; fi\nelse\n  if [[ $flag == \"add\" || $1 == \"add\" ]]; then addTask \"${*:2}\" && getTasks || exit 1\n  elif [[ $flag == \"remove\" || $1 == \"remove\" ]]; then removeTask \"${*:2}\" && getTasks || exit 1\n  else { usage; exit 1; }; fi\nfi\n"
  },
  {
    "path": "transfer/transfer",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\nconfiguredDownloadClient=\"\"\nconfiguredUploadClient=\"\"\nconfiguredClient=\"\"\ncurrentVersion=\"1.23.0\"\ndown=\"false\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredDownloadClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredDownloadClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredDownloadClient=\"wget\"\n  elif command -v fetch &>/dev/null; then\n    configuredDownloadClient=\"fetch\"\n  else\n    echo \"Error: Downloading with this tool requires either curl, wget, or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed.\" >&2\n    return 1\n  fi\n}\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetconfiguredUploadClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredUploadClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredUploadClient=\"wget\"\n  else\n    echo \"Error: Uploading with this tool requires either curl or wget to be installed.\" >&2\n    return 1\n  fi\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nsingleUpload()\n{\n  filePath=$(echo \"$1\" | sed s:\"~\":\"$HOME\":g)\n  if [ ! -f \"$filePath\" ];then { echo \"Error: invalid file path\"; return 1;}; fi\n  tempFileName=$(echo \"$1\" | sed \"s/.*\\///\")\n  echo \"Uploading $tempFileName\"\n  httpSingleUpload \"$filePath\" \"$tempFileName\"\n}\n\n\nhttpSingleUpload()\n{\n  case \"$configuredUploadClient\" in\n    curl) response=$( curl --progress-bar --upload-file $1 \"https://free.keep.sh\" | tee /dev/null) || { echo \"Failure!\"; return 1;};;\n    wget) response=$(wget --progress=dot --method PUT --body-file=\"$1\" \"https://free.keep.sh\" | tee /dev/null) || { echo \"Failure!\"; return 1;} ;;\n  esac\n  echo  \"Success!\"\n}\n\nprintUploadResponse()\n{\nfileID=$(echo \"$response\" | cut -d \"/\" -f 4)\n  echo \"Transfer Download Command: transfer -d desiredOutputDirectory $fileID $tempFileName\"\n  echo \"Transfer File URL: $response\"\n  echo -e \"\\n\\n\\t Or scan this QR Code\"\n  qrify $response\n}\n\n\nonetimeUpload()\n{\n\tgetConfiguredClient\n    checkInternet || exit 0\n    getconfiguredUploadClient\n  \tresponse=$(curl --progress-bar -T $1 temp.sh)\n  \tdownlink=$(echo \"$response\")\n}\n\n\nprintOnetimeUpload()\n{\n  \techo -e \"\\n Download link: $downlink\"\n  \techo -e \"\\n\\n\\t Or scan this QR Code\"\n  \tqrify $downlink\n}\n\nsingleDownload()\n{\n  if [[ ! -d $1 ]];then \n  \t{\n  \t\techo \"Directory doesn't exist, creating it now...\";\n  \t\tmkdir -p \"$1\";\n  \t};\n  fi\n\n  tempOutputPath=$1\n  if [ -f \"$tempOutputPath/$3\" ];then\n  \techo -n \"File aleady exists at $tempOutputPath/$3, do you want to delete it? [Y/n] \";\n  \tread -r answer\n    if [[ \"$answer\" == [Yy] ]] ;then\n    \trm -rf \"$tempOutputPath\"/\"$3\";\n    \telse\n    \t\techo \"Stopping download\"\n    \t\treturn 1;\n    fi\n  fi\n  echo \"Downloading $3\"\n  curl -# -L https://free.keep.sh/$2/$3 > $1/$3 || { echo \"Failure\"; return 1;}\n  # curl -# -L https://temp.sh/$2/$3 > $1/$3 || { echo \"Failure\"; return 1;}\n  echo \"Success!\"\n}\n\nusage()\n{\n  cat <<EOF\nTransfer\nDescription: Quickly transfer files from the command line.\nUsage: transfer [flags] or transfer [flag] [args] or transfer [filePathToUpload]\n  -d  Download a single file\n      First arg: Output file directory\n      Second arg: File url id\n      Third arg: File name\n  -o  Onetime file upload\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  transfer ~/fileToTransfer.txt\n  transfer ~/firstFileToTransfer.txt ~/secondFileToTransfer.txt ~/thirdFileToTransfer.txt\n  transfer -d ~/outputDirectory fileID fileName\n  transfer -o ~/fileToTransfer.txt\nEOF\n}\n\nwhile getopts \"o:d:uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n      exit 1\n    ;;\n    h)  usage\n      exit 0\n    ;;\n    v)  echo \"Version $currentVersion\"\n      exit 0\n    ;;\n    u)\n      getConfiguredClient || exit 1\n      checkInternet || exit 1\n      update || exit 1\n      exit 0\n    ;;\n    o)\n      onetime=\"true\"\n    ;;\n    d)\n      down=\"true\"\n      if [ $# -lt 4 ];\n      \tthen\n      \t\techo \"Error: not enough arguments for downloading a file, see the usage\"; exit 1\n      fi\n      \n      if [ $# -gt 4 ];\n      \tthen\n      \t\techo \"Error: to many enough arguments for downloading a file, see the usage\"; exit 1\n      \tfi\n      inputFilePath=$(echo \"$*\" | sed s/-d//g | sed s/-o//g | cut -d \" \" -f 2)\n      inputID=$(echo \"$*\" | sed s/-d//g | sed s/-o//g | cut -d \" \" -f 3)\n      inputFileName=$(echo \"$*\" | sed s/-d//g | sed s/-o//g | cut -d \" \" -f 4)\n    ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n      exit 1\n    ;;\n  esac\ndone\n\nif [[ $# == \"0\" ]]; then\n  usage\n  exit 0\nelif [[ $# == \"1\" ]];then\n  if [[ $1 == \"help\" ]]; then\n    usage\n    exit 0\n  elif [[ $1 == \"update\" ]]; then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    update || exit 1\n    exit 0\n  elif [ -f \"$1\" ];then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    getconfiguredUploadClient || exit 1\n    singleUpload \"$1\" || exit 1\n    printUploadResponse\n    exit 0\n  else\n    echo \"Error: invalid filepath\"\n    exit 1\n  fi\nelse\n  if $down ;then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    getConfiguredDownloadClient || exit 1\n    singleDownload \"$inputFilePath\" \"$inputID\" \"$inputFileName\" || exit 1\n    exit 0\n  elif ! $down && ! $onetime; then\n    getConfiguredClient || exit 1\n    checkInternet || exit 1\n    getconfiguredUploadClient || exit 1\n    for path in \"$@\";do\n      singleUpload \"$path\" || exit 1\n      printUploadResponse\n      echo\n    done\n    exit 0\n  elif ! $down && $onetime; then\n    getConfiguredClient || exit 1\n    if [[ $configuredClient -ne \"curl\" ]];then\n      echo \"Error: curl must be installed to use one time file upload\"\n      exit 1\n    fi\n    inputFileName=$(echo \"$*\" | sed s/-o//g | cut -d \" \" -f 2 )\n    onetimeUpload \"$inputFileName\"\n    printOnetimeUpload\n  fi\nfi\n"
  },
  {
    "path": "uninstall.sh",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\ndeclare -a tools=(bak2dvd bash-snippets cheat cloudup crypt cryptocurrency currency geo gist lyrics meme movies newton pwned qrify short siteciphers stocks taste todo transfer weather ytview)\nall=\"1\"\n\naskUninstall()\n{\n  if [[ -f /usr/local/bin/$1 ]]; then\n    echo -n \"Do you wish to uninstall $1 [Y/n]: \"\n    read -r answer\n    if [[ \"$answer\" == [Yy] ]]; then\n      echo -n \"Removing $1: \"\n      rm -f /usr/local/bin/\"$1\" > /dev/null 2>&1 || { echo \"Failed\" ; echo \"Error removing file, try running uninstall script as sudo\"; exit 1; }\n      echo \"Success\"\n    else\n      all=\"0\"\n    fi\n    unset answer\n  fi\n}\n\nremoveTool()\n{\n  if [[ -f /usr/local/bin/$1 ]]; then\n    echo -n \"Removing $1: \"\n    rm -f /usr/local/bin/\"$1\" > /dev/null 2>&1 || { echo \"Failed\" ; echo \"Error removing file, try running uninstall script as sudo\"; exit 1; }\n    echo \"Success\"\n  fi\n}\n\nremoveManpage()\n{\n  if [ -f \"/usr/local/man/man1/bash-snippets.1\" ]; then rm -f \"usr/local/man/man1/bash-snippets.1\" || { echo \"Error removing manpage, try running uninstall script as sudo\"; exit 1; } ; fi\n  if [ -f \"/usr/local/share/man/man1/bash-snippets.1\" ]; then rm -f \"/usr/local/share/man/man1/bash-snippets.1\" || { echo \"Error removing manpage, try running uninstall script as sudo\"; exit 1; } ; fi\n}\n\nif [[ $1 != \"all\" ]]; then\n  for tool in \"${tools[@]}\"; do\n    askUninstall \"$tool\" || exit 1\n  done\nelse\n  for tool in \"${tools[@]}\"; do\n    removeTool \"$tool\" || exit 1\n  done\nfi\n\nif [[ $all == \"1\" ]]; then\n  removeManpage || exit 1\nfi\n"
  },
  {
    "path": "weather/weather",
    "content": "#!/usr/bin/env bash\n# Author: Alexander Epstein https://github.com/alexanderepstein\n\ncurrentVersion=\"1.23.0\" #This version variable should not have a v but should contain all other characters ex Github release tag is v1.2.4 currentVersion is 1.2.4\nLANG=\"${LANG:-en}\"\nlocale=$(echo \"$LANG\" | cut -c1-2)\nunset configuredClient\nif [[ $(echo \"$locale\" | grep -Eo \"[a-z A-Z]*\" | wc -c) != 3 ]]; then locale=\"en\"; fi\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed\\.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ngetIPWeather()\n{\n  country=$(httpGet ipinfo.io/country) > /dev/null ## grab the country\n  if [[ $country == \"US\" ]]; then ## if were in the us id rather not use longitude and latitude so the output is nicer\n    city=$(httpGet ipinfo.io/city) > /dev/null\n    region=$(httpGet ipinfo.io/region) > /dev/null\n    if [[ $(echo \"$region\" | wc -w) == 2 ]];then\n      region=$(echo \"$region\" | grep -Eo \"[A-Z]*\" | tr -d \"[:space:]\")\n    fi\n    httpGet $locale.wttr.in/\"$city\",\"$region\"\"$1\"\n  else ## otherwise we are going to use longitude and latitude\n    location=$(httpGet ipinfo.io/loc) > /dev/null\n    httpGet $locale.wttr.in/\"$location\"\"$1\"\n  fi\n}\n\ngetLocationWeather()\n{\n  args=$(echo \"$@\" | tr \" \" + )\n  httpGet $locale.wttr.in/\"${args}\"\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\nusage()\n{\n  cat <<EOF\nWeather\nDescription: Provides a 3 day forecast on your current location or a specified location.\n  With no flags Weather will default to your current location.\nUsage: weather or weather [flag] or weather [country] or weather [city] [state]\n  weather [i][M] get weather in imperial units, optional M means windspeed in m/s\n  weather [m][M] get weather in metric units, optional M means windspeed in m/s\n  weather [Moon] grabs the phase of the moon\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  weather\n  weather Paris m\n  weather Tokyo\n  weather Moon\n  weather mM\nEOF\n}\n\ngetConfiguredClient || exit 1\n\nwhile getopts \"uvh\" opt; do\n  case \"$opt\" in\n    \\?) echo \"Invalid option: -$OPTARG\" >&2\n        exit 1\n        ;;\n    h)  usage\n        exit 0\n        ;;\n    v)  echo \"Version $currentVersion\"\n        exit 0\n        ;;\n    u)  checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here\n        update || exit 1\n        exit 0\n        ;;\n    :)  echo \"Option -$OPTARG requires an argument.\" >&2\n        exit 1\n        ;;\n  esac\ndone\n\nif [[ $# == \"0\" ]]; then\n  checkInternet || exit 1\n  getIPWeather || exit 1\n  exit 0\nelif [[ $1 == \"help\" || $1 == \":help\" ]]; then\n  usage\n  exit 0\nelif [[ $1 == \"update\" ]]; then\n  checkInternet || exit 1\n  update || exit 1\n  exit 0\nfi\n\ncheckInternet || exit 1\nif [[ $1 == \"m\" ]]; then\n  getIPWeather \"?m\" || exit 1\nelif [[ \"${@: -1}\" == \"m\" ]];then\n  args=$( echo \"${@:1:(($# - 1))}\" ?m | sed s/\" \"//g)\n  getLocationWeather \"$args\" || exit 1\nelif [[ $1 == \"M\" ]]; then\n  getIPWeather \"?M\" || exit 1\nelif [[ \"${@: -1}\" == \"M\" ]];then\n  args=$( echo \"${@:1:(($# - 1))}\" ?M | sed s/\" \"//g)\n  getLocationWeather \"$args\" || exit 1\nelif [[ $1 == \"mM\" || $1 == \"Mm\" ]]; then\n  getIPWeather \"?m?M\" || exit 1\nelif [[ \"${@: -1}\" == \"mM\" || \"${@:-1}\" == \"Mm\" ]];then\n  args=$( echo \"${@:1:(($# - 1))}\" ?m?M | sed s/\" \"//g)\n  getLocationWeather \"$args\" || exit 1\nelif [[ $1 == \"iM\" || $1 == \"Mi\" ]]; then\n  getIPWeather \"?u?M\" || exit 1\nelif [[ \"${@: -1}\" == \"iM\" || \"${@:-1}\" == \"Mi\" ]];then\n  args=$( echo \"${@:1:(($# - 1))}\" ?u?M | sed s/\" \"//g)\n  getLocationWeather \"$args\" || exit 1\nelif [[ $1 == \"i\" ]]; then\n  getIPWeather \"?u\" || exit 1\nelif [[ \"${@: -1}\" == \"i\" ]];then\n  args=$( echo \"${@:1:(($# - 1))}\" ?u | sed s/\" \"//g)\n  getLocationWeather \"$args\" || exit 1\nelse\n  getLocationWeather \"$@\" || exit 1\nfi\n"
  },
  {
    "path": "ytview/ytview",
    "content": "#!/usr/bin/env bash\n# Author: Linyos Torovoltos https://github.com/linyostorovovoltos\n# Modifications: Alexander Epstein https://github.com/alexanderepstein\n\nif [[ -d $HOME/.cache/ytview ]]; then rm -rf \"$HOME\"/.cache/ytview/; fi\n\nplayer=\"\"\nconfiguredClient=\"\"\ncurrentVersion=\"1.23.0\"\nflag=\"\"\n\n## This function determines which http get tool the system has installed and returns an error if there isnt one\ngetConfiguredClient()\n{\n  if  command -v curl &>/dev/null; then\n    configuredClient=\"curl\"\n  elif command -v wget &>/dev/null; then\n    configuredClient=\"wget\"\n  elif command -v http &>/dev/null; then\n    configuredClient=\"httpie\"\n  elif command -v fetch &>/dev/null; then\n    configuredClient=\"fetch\"\n  else\n    echo \"Error: This tool requires either curl, wget, httpie or fetch to be installed\\.\" >&2\n    return 1\n  fi\n}\n\n## Allows to call the users configured client without if statements everywhere\nhttpGet()\n{\n  case \"$configuredClient\" in\n    curl)  curl -A curl -s \"$@\" ;;\n    wget)  wget -qO- \"$@\" ;;\n    httpie) http -b GET \"$@\" ;;\n    fetch) fetch -q \"$@\" ;;\n  esac\n}\n\ncheckInternet()\n{\n  httpGet github.com > /dev/null 2>&1 || { echo \"Error: no active internet connection\" >&2; return 1; } # query github with a get request\n}\n\nupdate()\n{\n  # Author: Alexander Epstein https://github.com/alexanderepstein\n  # Update utility version 2.2.0\n  # To test the tool enter in the defualt values that are in the examples for each variable\n  repositoryName=\"Bash-Snippets\" #Name of repostiory to be updated ex. Sandman-Lite\n  githubUserName=\"alexanderepstein\" #username that hosts the repostiory ex. alexanderepstein\n  nameOfInstallFile=\"install.sh\" # change this if the installer file has a different name be sure to include file extension if there is one\n  latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '\"name\":.*?[^\\\\]\",'| head -1 | grep -Eo \"[0-9.]+\" ) #always grabs the tag without the v option\n\n  if [[ $currentVersion == \"\" || $repositoryName == \"\" || $githubUserName == \"\" || $nameOfInstallFile == \"\" ]]; then\n    echo \"Error: update utility has not been configured correctly.\" >&2\n    exit 1\n  elif [[ $latestVersion == \"\" ]]; then\n    echo \"Error: no active internet connection\" >&2\n    exit 1\n  else\n    if [[ \"$latestVersion\" != \"$currentVersion\" ]]; then\n      echo \"Version $latestVersion available\"\n      echo -n \"Do you wish to update $repositoryName [Y/n]: \"\n      read -r answer\n      if [[ \"$answer\" == [Yy] ]]; then\n        cd ~ || { echo 'Update Failed'; exit 1; }\n        if [[ -d  ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo \"Permissions Error: try running the update as sudo\"; exit 1; } ; fi\n        echo -n \"Downloading latest version of: $repositoryName.\"\n        git clone -q \"https://github.com/$githubUserName/$repositoryName\" && touch .BSnippetsHiddenFile || { echo \"Failure!\"; exit 1; } &\n        while [ ! -f .BSnippetsHiddenFile ]; do { echo -n \".\"; sleep 2; };done\n        rm -f .BSnippetsHiddenFile\n        echo \"Success!\"\n        cd $repositoryName || { echo 'Update Failed'; exit 1; }\n        git checkout \"v$latestVersion\" 2> /dev/null || git checkout \"$latestVersion\" 2> /dev/null || echo \"Couldn't git checkout to stable release, updating to latest commit.\"\n        chmod a+x install.sh #this might be necessary in your case but wasnt in mine.\n        ./$nameOfInstallFile \"update\" || exit 1\n        cd ..\n        rm -r -f $repositoryName || { echo \"Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo\"; exit 1; }\n      else\n        exit 1\n      fi\n    else\n      echo \"$repositoryName is already the latest version\"\n    fi\n  fi\n}\n\ngetConfiguredPlayer()\n{\n  if [ ! -z \"${YTVIEWPLAYER+x}\" ]; then\n    player=\"$YTVIEWPLAYER\"\n    return 0\n  fi\n  if [[ $(uname -s) == \"Linux\" ]]; then\n    if command -v vlc &>/dev/null; then\n      player=\"vlc\"\n    elif command -v mpv &>/dev/null; then\n      player=\"mpv\"\n    elif command -v mplayer &>/dev/null; then\n      player=\"mplayer\"\n    else\n      echo \"Error: no supported video player installed (vlc, mpv or mplayer)\" >&2\n      return 1\n    fi\n  elif [[ $(uname -s) == \"Darwin\" ]]; then\n    if [[ -f /Applications/VLC.app/Contents/MacOS/VLC ]]; then\n      player=\"/Applications/VLC.app/Contents/MacOS/VLC\"\n    elif [[ -f $HOME/Applications/VLC.app/Contents/MacOS/VLC ]]; then\n      player=\"$HOME/Applications/VLC.app/Contents/MacOS/VLC\"\n    elif command -v mpv &>/dev/null; then\n      player=\"mpv\"\n    elif [[ -f /Applications/mpv.app/Contents/MacOS/mpv ]]; then\n      player=\"/Applications/mpv.app/Contents/MacOS/mpv\"\n    elif [[ -f $HOME/Applications/mpv.app/Contents/MacOS/mpv ]]; then\n      player=\"$HOME/Applications/mpv.app/Contents/MacOS/mpv\"\n    else\n\t  if [[ $(mdutil -s / | grep \"Indexing enabled.\" 2>/dev/null) != \"\" ]]; then\n\t    vlc_md=$(mdfind kMDItemCFBundleIdentifier = \"org.videolan.vlc\" 2>/dev/null)\n\t    if [[ $vlc_md != \"\" ]]; then\n\t      player=\"$vlc_md/Contents/MacOS/VLC\"\n\t    else\n\t      mpv_md=$(mdfind kMDItemCFBundleIdentifier = \"io.mpv\" 2>/dev/null)\n\t      if [[ $mpv_md != \"\" ]]; then\n\t        player=\"$mpv_md/Contents/MacOS/mpv\"\n\t      else\n\t        echo \"Error: no supported video player installed (VLC or mpv)\" >&2\n\t        return 1\n\t      fi\n\t    fi\n\t  else\n\t    echo \"Error: no supported video player installed (VLC or mpv)\" >&2\n\t    return 1\n\t  fi\n    fi\n  fi\n}\n\n# Get the video titles\nchannelview()\n{\n  mkdir -p \"$HOME\"/.cache/ytview/channels/\"$channel\" || return 1\n  httpGet \"https://www.youtube.com/user/$channel/videos?hl=en\" | grep \"Duration\" | awk '{print $10 \" \" $11 \" \" $12 \" \" $13 \" \" $14 \" \" $15 \" \" $16 \" \" $17 \" \" $18 \" \" $19 \" \" $20 \" \" $21 \" \" $22 \" \" $23 \" \" $24 \" \" $25 \" \" $26 \" \" $27 \" \" $29}' | sed 's/aria-describedby=\"description-id.*//' | sed s/title=// | sed 's/\"//' | sed 's/\"//' | awk '{printf \"%s.\\t%s\\n\",NR,$0}'  | sed  s/'&#39;'/\"'\"/g | sed s/'&amp;'/'and'/g | sed s/\\&quot\\;/\\\"/g > \"$HOME\"/.cache/ytview/channels/\"$channel\"/titles.txt || return 1\n\n  # Get the video urls\n  httpGet \"https://www.youtube.com/user/$channel/Videos?hl=en\" | grep \"watch?v=\" | awk '{print $6}' | sed s/spf-link// | sed s/href=// | sed 's/\"//' | sed 's/\"//' | sed '/^\\s*$/d' | sed 's/\\//https:\\/\\/www.youtube.com\\//' | awk '{printf \"%s.\\t%s\\n\",NR,$0}' > \"$HOME\"/.cache/ytview/channels/\"$channel\"/urls.txt || return 1\n\n  # Print 20 first video titles for the user to choose from\n  head -n 20 \"$HOME\"/.cache/ytview/channels/\"$channel\"/titles.txt || return 1\n  # Prompt the user for video number\n  read -p \"Choose a video: \" titlenumber\n  if [[ -n ${titlenumber//[0-9]/} ]]; then\n    echo \"Canceled.\" >&2\n    exit 0\n  fi\n\n  # Play the video with your player\n  $player $(sed -n $(echo \"$titlenumber\")p < \"$HOME\"/.cache/ytview/channels/\"$channel\"/urls.txt | awk '{print $2}') > /dev/null 2>&1 &\n}\n\nsearchview()\n{\n  search=$(echo \"$search\" | tr \" \" + )\n  mkdir -p \"$HOME\"/.cache/ytview/searches/\"$search\"\n\n  #Get video titles\n  httpGet \"https://www.youtube.com/results?hl=en&search_query=$search\" | grep \"Duration\" | grep \"watch?v=\" | awk '{print $13 \" \" $14 \" \" $15 \" \" $16 \" \" $17 \" \" $18 \" \" $19 \" \" $20 \" \" $21 \" \" $22 \" \" $23 \" \" $23}' | sed 's/aria-describedby=\"description-id.*//g' | sed s/title=// | sed 's/\"//g' | sed s/spf-link// | sed 's/data-session-link=itct*.//' | sed s/spf-prefetch//g | sed 's/rel=//g' | sed 's/\"//' | awk '{printf \"%s.\\t%s\\n\",NR,$0}' | sed  s/'&#39;'/\"'\"/g | sed  s/'&amp;'/'and'/g | sed s/\\&quot\\;/\\\"/g > \"$HOME\"/.cache/ytview/searches/\"$search\"/titles.txt || return 1\n\n  #Get video urls\n  httpGet \"https://www.youtube.com/results?hl=en&search_query=$search\" | grep \"watch?v=\" | awk '{print $5}' | sed s/vve-check// | sed 's/href=\"/https:\\/\\/www.youtube.com/' | sed 's/\"//' | sed s/class=\"yt-uix-tile-link\"// | sed '/^\\s*$/d' | awk '{printf \"%s.\\t%s\\n\",NR,$0}' > \"$HOME\"/.cache/ytview/searches/\"$search\"/urls.txt || return 1\n  #Print 20 first video titles for the user to choose from\n  cat \"$HOME\"/.cache/ytview/searches/\"$search\"/titles.txt || return 1\n\n  #Let the user choose the video number\n  read -p \"Choose a video: \" titlenumber\n  if [[ -n ${titlenumber//[0-9]/} ]]; then\n    echo \"Canceled.\" >&2\n    exit 0\n  fi\n\n  #Play the video with your favorite player\n  $player $(sed -n $(echo \"$titlenumber\")p < \"$HOME\"/.cache/ytview/searches/\"$search\"/urls.txt | awk '{print $2}') > /dev/null 2>&1 &\n}\n\nusage()\n{\n  cat <<EOF\nYtview\nDescription: Search and play youtube videos right from the terminal.\nUsage: ytview [flag] [string] or ytview [videoToSearch]\n  -s  Searches youtube\n  -c  Shows the latest videos of a channel\n  -u  Update Bash-Snippet Tools\n  -h  Show the help\n  -v  Get the tool version\nExamples:\n  ytview -s Family Guy Chicken Fight\n  ytview -c Numberphile\nEOF\n}\n\ngetConfiguredClient || exit 1\n\n\nwhile getopts \"vuc:s:h*:\" option; do\n  case \"${option}\" in\n    s) if [[ $flag != \"channel\" ]]; then\n         search=$(printf '%s ' \"$@\")\n         flag=\"search\"\n       else\n         echo \"Error: search and channel options are mutually exclusive\" >&2\n         exit 1\n       fi\n        ;;\n    c) if [[ $flag != \"search\" ]]; then\n         channel=\"$OPTARG\"\n         flag=\"channel\"\n       else\n         echo \"Error: search and channel options are mutually exclusive\" >&2\n         exit 1\n       fi\n       ;;\n    h) usage && exit 0 ;;\n    u) checkInternet && update && exit 0 || exit 1;;\n    v) echo \"Version $currentVersion\" && exit 0 ;;\n    *) usage && exit 0 ;;\n  esac\ndone\n\nif [[ $# == \"0\" ]]; then\n  usage\n  exit 0\nelif [[ $1 == \"help\" ]]; then\n  usage\n  exit 0\nelif [[ $1 == \"update\" ]]; then\n  checkInternet || exit 1\n  update\n  exit 0\nelif [[ $flag == \"search\" ]]; then\n  checkInternet || exit 1\n  getConfiguredPlayer || exit 1\n  searchview || exit 1\nelif [[ $flag == \"channel\" ]]; then\n  checkInternet || exit 1\n  getConfiguredPlayer || exit 1\n  channelview || exit 1\nelse\n  checkInternet || exit 1\n  search=$(printf '%s ' \"$@\")\n  getConfiguredPlayer || exit 1\n  searchview || exit 1\nfi\n"
  }
]