[
  {
    "path": ".github/stale.yml",
    "content": "# Number of days of inactivity before an issue becomes stale\ndaysUntilStale: 60\n# Number of days of inactivity before a stale issue is closed\ndaysUntilClose: 7\n# Issues with these labels will never be considered stale\nexemptLabels:\n  - pinned\n  - security\n# Label to use when marking an issue as stale\nstaleLabel: wontfix\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: false\n"
  },
  {
    "path": ".gitignore",
    "content": ".DS_Store\n.idea/\n.idea/workspace.xml\n.phpstorm.meta.php\n*.iml"
  },
  {
    "path": "LICENSE.md",
    "content": "Copyright (c) 2015-2022 Gabriel Guarino\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": "README.md",
    "content": "# Mac CLI\n\n macOS command line tools for developers\n\n\n---\n\n### Sponsors\n\n>[![Sponsor logo](images/sponsor-icon.png)](https://apps.apple.com/us/app/superplanner/id6443725564)\n>\n>Mac CLI is sponsored by 📒 [SuperPlanner](https://superplanner.app/), an innovative daily planner and task manager for iPhone, iPad and Mac.\n>\n>SuperPlanner combines the calendar with task management features to keep everything organized in one place.\n>\n>There is no login or user registration required. All data is stored locally and syncs between your devices using private and secure iCloud sync.\n>\n>[![Sponsor download badge](images/sponsor-download-badge.png)](https://apps.apple.com/us/app/superplanner/id6443725564)\n\n---\n\n### Introduction\n\nMac CLI is the ultimate tool for developers to manage their Mac. It provides a huge set of command line commands that automate the usage of your macOS system.\nWhen you run a function, the executed command is displayed and that helps you memorize each of the Utilities for future usage.\n\nThe tool is designed to be easily extendable with additional commands through the use of plugins. To view the currently available commands, you can navigate to the plugins folder and explore the different categories: [/mac-cli/plugins](https://github.com/guarinogabriel/mac-cli/tree/master/mac-cli/plugins)\n\n_Contributions to add new plugins and keep improving the existing ones are welcome and very much appreciated!_\n\n![image](images/demo.gif)\n\n---\n\n### Installation in 1 Simple Step - Including Configuration Wizard!\n\nVia curl\n> `sh -c \"$(curl -fsSL https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/install)\"`\n\nVia wget\n> `sh -c \"$(wget https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/install -O -)\"`\n\nThen, re-open your terminal client. You will be able to run all the commands listed below, for example:\n> `mac help`\n\n---\n\n### Configuration\n\nThe configuration is done when you install Mac CLI for the first time though the installer configuration wizard.\nAfter that, you can update your Mac CLI configuration by editing the following file: `/usr/local/bin/mac`\n\n---\n\n### Requirements\n\nThese are the requirements to be able to run all the commands (the dependencies/requirements are installed when you install Mac CLI for the first time):\n\n* Homebrew\n* Git\n* Pipe Viewer (pv)\n\n---\n\n### Update\n\nYou can update Mac CLI to the latest version by running:\n> `sh -c \"$(curl -fsSL https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/update)\"`\n\n---\n\n### Uninstallation\n\nYou can uninstall Mac CLI by running:\n> `sh -c \"$(curl -fsSL https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/uninstall)\"`\n\n---\n\n### Help / Commands List\n\n| Command  | Description | Arguments |\n| ------------- | ------------- | ------------- |\n| `mac help`  | List all available commands in mac script  | |\n\n### General Commands\n\n| Command  | Description | Arguments |\n| ------------- | ------------- | ------------- |\n| `mac update`  | Install macOS software updates, update installed Ruby gems, Homebrew, npm and their installed packages | |\n| `mac lock`  | Lock  | |\n| `mac restart`  | Restart macOS  | |\n| `mac sleep`  | Sleep mode  | |\n| `mac shutdown`  | Shutdown  | |\n| `mac time`  | Show clock at top right position in Terminal/iTerm | |\n| `mac screensaver`  | Start screensaver  | |\n| `mac folders:list`  | List folders in current directory with their current size | |\n| `mac folder:size`  | Calculate current folder size  | |\n| `mac bluetooth:status`  | Get the bluetooth status  | |\n| `mac bluetooth:enable`  | Enable bluetooth  | |\n| `mac bluetooth:disable`  | Disable bluetooth  | |\n| `mac wifi:status`  | Get the wifi status  | |\n| `mac wifi:scan`  | Scan available wifi networks  | |\n| `mac wifi:enable`  | Enable wifi  | |\n| `mac wifi:disable`  | Disable wifi  | |\n| `mac dock:add-space N`  | Add blank space to dock  | N = number of spaces |\n| `mac eject-all`  | Eject all mounted volumes and disks  | |\n| `mac battery`  | Get battery status  | |\n| `mac info`  | Get macOS version information  | |\n| `mac hidden:show`  | Show hidden files  | |\n| `mac hidden:hide`  | Hide hidden files  | |\n| `mac find:text X`  | Find exact phrase recursively inside directory | X = Text string |\n| `mac find:biggest-files`  | Find biggest files inside directory  | |\n| `mac find:biggest-directories`  | Find biggest directories inside directory | |\n| `mac zip:extract X` | Extract Zip file to current folder | X = Zip file to extract |\n| `mac gzip:compress X` | Compress current file using Gzip | X = File to compress |\n| `mac gzip:extract X` | Extract Gzip file to current folder | X = Gzip file to extract |\n| `mac tar:compress X`  | Compress X file/directory using tar with progress indicator | X = File or directory |\n| `mac tar:extract X` | Extract tar file to current folder | X = Tar file to extract |\n\n\n### Search Utilities\n\n| Command  | Description | Arguments |\n| ------------- | ------------- | ------------- |\n| `mac find:recent N`  | Find files modified in the last N minutes  |  N = number of minutes  |\n| `mac search:replace X` | Search and replace string in file | X = File to perform the search and replace operation |\n\n\n### Network Utilities\n\n| Command  | Description |\n| ------------- | ------------- |\n| `mac speedtest`  | Internet connection speed test  |\n| `mac ports`  | List of used ports  |\n| `mac ip:local`  | Get local IP address  |\n| `mac ip:public`  | Get public IP address  |\n\n\n### DNS Utilities\n\n| Command  | Description |\n| ------------- | ------------- |\n| `mac dns:list`  | List DNS server(s)  |\n| `mac dns:add`  | Add DNS server  |\n| `mac dns:remove`  | Remove DNS server  |\n| `mac dns:flush`  | Flush DNS cache  |\n\n\n### SSH Utilities\n\n| Command  | Description | Arguments |\n| ------------- | ------------- | ------------- |\n| `mac ssh:download-file X`  | Download file from remote server through SSH  |  X = Path of the remote file to download  |\n| `mac ssh:download-folder X`  | Download entire folder from remote server through SSH  |  X = Path of the remote folder to download  |\n| `mac ssh:sync:local X`  | Sync local folder with remote folder using rsync through SSH (download remote folder to local folder)  |  X = Path of the remote folder to sync to local folder  |\n| `mac ssh:sync:remote X`  | Sync remote folder with local folder using rsync through SSH (upload local folder to remote folder)  |  X = Path of the remote folder to sync from local folder  |\n| `mac ssh:upload X`  | Upload file to remote server through SSH  |  X = Path of the file to upload to the remote server  |\n| `mac ssh:public-key`  | Copy SSH Public Key  |  |\n| `mac ssh:list`  | List all the saved SSH credentials  |  |\n\n\n### Performance and maintenance Utilities\n\n| Command  | Description |\n| ------------- | ------------- |\n| `mac system`  | Show system information to review mac performance  |\n| `mac temp`  | Show temperature, fan and battery statistics  |\n| `mac memory`  | See memory usage sorted by memory consumption  |\n| `mac trash:empty`  | Empty trash |\n| `mac trash:size`  | Calculate trash size |\n\n\n### Git Utilities\n\n| Command  | Description |\n| ------------- | ------------- |\n| `mac git:config`  | Display local Git configuration  |\n| `mac git:open`  | Open current repository on Github  |\n| `mac git:create:branch`  | Create branch based on current branch  |\n| `mac git:branches:date`  | Get last update date for all branches in current project  |\n| `mac git:undo-commit`  | Undo latest commit  |\n| `mac git:log`  | See latest commits IDs and titles for current branch  |\n| `mac git:branch`  | See all branches  |\n| `mac git:branch:rename`  | Rename Git branch |\n| `mac git:branch:remove-local`  | Remove local Git branch |\n| `mac git:branch:remove-remote`  | Remove local and remote Git branch |\n| `mac git:settings`  | Check Git settings  |\n| `mac git:add-removed`  | Add removed files to staged files  |\n| `mac git:size`  | Get size for current Git directory  |\n\n### Homebrew Utilities\n\n| Command  | Description |\n| ------------- | ------------- |\n| `mac brew`  | Get a list of installed Homebrew packages  |\n"
  },
  {
    "path": "mac",
    "content": "#!/bin/sh\n###########################################################################\n#  mac CLI (mac command line tools) - macOS command line tools for developers\n###########################################################################\n\n# Version: 2.0\n# Date: December 8, 2015\n# Author: Gabriel Guarino\n#\n# Collection of useful functions to automate macOS common tasks\n#\n###########################################################################\n\n# Mac CLI directory\nMAC=\"$(dirname \"$0\")\"\n\n#--------------------------------------------------------------------\n# Configuration\n#--------------------------------------------------------------------\nexport echocommand=\"true\"\n\n#--------------------------------------------------------------------\n# Parameters\n#--------------------------------------------------------------------\nexport fn=$1\nexport firstParameter=$2\nexport secondParameter=$3\nexport allParameters=${@:2}\n\n#--------------------------------------------------------------------\n# Colors\n#--------------------------------------------------------------------\nexport GREEN='\\033[0;32m'\nexport GRAY='\\033[0;37m'\nexport LIGHTBLUE='\\033[1;34m'\nexport LIGHTGREEN='\\033[1;32m'\nexport WHITEBOLD='\\033[1;37m'\nexport RED='\\033[1;31m'\nexport NC='\\033[0m' # No Color\n\n#--------------------------------------------------------------------\n# List of Commands\n#--------------------------------------------------------------------\n\nCOMMANDS=(\n    list\n    help\n    usage\n    categories\n    general\n    search\n    network\n    dns\n    ssh\n    webdev\n    performance\n    terminal\n    git\n    web_utilities\n    homebrew\n    image\n    magento\n    update\n    upgrade\n    uninstall\n    lock\n    restart\n    sleep\n    display\n    shutdown\n    uptime\n    volume\n    volume:ismute\n    volume:mute\n    volume:unmute\n    hidden:show\n    hidden:hide\n    screensaver\n    folders:list\n    folder:size\n    dock:add-space\n    bluetooth:status\n    bluetooth:enable\n    bluetooth:disable\n    wifi:status\n    wifi:scan\n    wifi:enable\n    wifi:disable\n    eject-all\n    battery\n    info\n    find:text\n    find:biggest-files\n    find:biggest-directories\n    zip:extract\n    gzip:compress\n    gzip:extract\n    tar:compress\n    tar:extract\n    find:recent\n    search:replace\n    speedtest\n    ports\n    ip:local\n    ip:public\n    dns:list\n    dns:add\n    dns:remove\n    dns:flush\n    hosts:edit\n    ssh:download-file\n    ssh:download-folder\n    ssh:sync:local\n    ssh:sync:remote\n    ssh:upload\n    ssh:public-key\n    ssh:list\n    system\n    temp\n    memory\n    trash:empty\n    trash:size\n    git:config\n    git:open\n    git:create:branch\n    git:branches:date\n    git:undo-commit\n    git:log\n    git:branch\n    git:branch:rename\n    git:branch:remove-local\n    git:branch:remove-remote\n    git:branch\n    git:settings\n    git:add-removed\n    git:size\n    brew:update\n)\n## ---- END OF COMMANDS; Comment required for bash_completion------\n\nif [ -z \"$fn\" ] || [[ \"$#\" -lt \"1\" ]]; then\n    fn=\"list\"\nfi\n\n#--------------------------------------------------------------------\n# Help\n#--------------------------------------------------------------------\n\n# Documentation / Help\nsource \"$MAC/mac-cli/misc/help\"\n\n#--------------------------------------------------------------------\n# Catch command not found\n#--------------------------------------------------------------------\n\nif [[ ! \" ${COMMANDS[@]} \" =~ \" ${fn} \" ]]; then\n    echo \"${RED}Command not found: '${fn}' $(test ! -z \"$allParameters\" -a \"$allParameters\" != \" \" && echo \"\\nParameters: $allParameters\" || echo \"\")${NC}\"\n    read -p \"Choose a category for which to list help/usage... ($(categoriesList)) \" category # Ask user for a category to print usage\n\n    if [ ! -z \"${category}\" ]; then\n        echo \"$(usageList ${category})\\n\" # Show help/usage for user-selected category\n        echo \"$(printAdditionalHelp)\"\n    else\n        kill -INT $$ # Exit\n    fi\nfi\n\n#--------------------------------------------------------------------\n# Plugins\n#--------------------------------------------------------------------\n\nsource \"$MAC/mac-cli/plugins/brew\"\nsource \"$MAC/mac-cli/plugins/general\"\nsource \"$MAC/mac-cli/plugins/git\"\nsource \"$MAC/mac-cli/plugins/network\"\nsource \"$MAC/mac-cli/plugins/dns\"\nsource \"$MAC/mac-cli/plugins/performance\"\nsource \"$MAC/mac-cli/plugins/search\"\nsource \"$MAC/mac-cli/plugins/ssh\"\nsource \"$MAC/mac-cli/plugins/volume\"\n"
  },
  {
    "path": "mac-cli/completion/bash_completion",
    "content": "# Mac_CLI bash completion\n\nhave mac && {\n_mac() {\n    local MACWORDS cur\n\n    COMPREPLY=()\n    _get_comp_words_by_ref -n : cur\n\n    MACWORDS=$(awk \"/COMMANDS=/,/#/\" < /usr/local/bin/mac  | tail -n +2 | sed '/)/d;/#/d')\n\n    COMPREPLY=( $( compgen -W \"$MACWORDS\" -- \"$cur\" ) )\n\n    __ltrim_colon_completions \"$cur\"\n}\ncomplete -F _mac mac\n}"
  },
  {
    "path": "mac-cli/completion/fish_completion",
    "content": "complete -c mac -a (awk \"/COMMANDS=/,/#/\" < /usr/local/bin/mac  | tail -n +2 | sed '/)/d;/#/d' | tr -d '\\n')\n"
  },
  {
    "path": "mac-cli/misc/help",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# mac script commands list - all commands\n#--------------------------------------------------------------------\n\nMacCategories=(\ngeneral\ngit\nhomebrew\nlamp\nnetwork\ndns\nperformance\nsearch\nssh\nterminal\nweb_utilities\nwebdev\n)\n\nfunction printInfo()\n{\n    echo \"\\n${WHITEBOLD} mac CLI – OS X command line tools for developers\"\n    echo \"====================================================${NC}\"\n}\n\nfunction printAdditionalHelp()\n{\n    echo \"\\nRun ${LIGHTBLUE}mac help${NC} for full usage, ${LIGHTBLUE}mac categories${NC} for categories list, or ${LIGHTBLUE}mac {category}${NC} for usage related to {category}\"\n    echo \"${NC}\\n\"\n}\n\nfunction categoriesList()\n{\n    cats=${cats}$(printf \"%s|\" \"${MacCategories[@]}\")\n    cats=\"${cats%?}\"\n    echo \"${cats}\"\n}\n\nfunction usageList()\n{\n    case ${1} in\n        general)\n            echo \"\\n${WHITEBOLD}General Utilities: \"\n            echo \"${LIGHTBLUE}mac update${GRAY}: Install OS X software updates, update installed Ruby gems, Homebrew, npm and their installed packages\"\n            echo \"${LIGHTBLUE}mac upgrade${GRAY}: Upgrade Mac CLI to the latest version\"\n            echo \"${LIGHTBLUE}mac uninstall${GRAY}: Uninstall Mac CLI\"\n            echo \"${LIGHTBLUE}mac lock${GRAY}: Lock\"\n            echo \"${LIGHTBLUE}mac restart${GRAY}: Restart OS X\"\n            echo \"${LIGHTBLUE}mac sleep${GRAY}: Sleep mode\"\n            echo \"${LIGHTBLUE}mac shutdown${GRAY}: Shutdown\"\n            echo \"${LIGHTBLUE}mac uptime${GRAY}: Get the time since last restart\"\n            echo \"${LIGHTBLUE}mac volume${GRAY}: Get the volume from the terminal\"\n            echo \"${LIGHTBLUE}mac volume ${LIGHTGREEN}X${GRAY}: Set the volume from the terminal - ${LIGHTGREEN}X = Level (0-100)\"\n            echo \"${LIGHTBLUE}mac volume:mute${GRAY}: Mute volume\"\n            echo \"${LIGHTBLUE}mac volume:unmute${GRAY}: Unmute volume\"\n            echo \"${LIGHTBLUE}mac volume:ismute${GRAY}: Check if the volume is muted or not\"\n            echo \"${LIGHTBLUE}mac screensaver${GRAY}: Start screensaver\"\n            echo \"${LIGHTBLUE}mac folders:list${GRAY}: List folders in current directory with their current size\"\n            echo \"${LIGHTBLUE}mac folder:size${GRAY}: Calculate current folder size\"\n            echo \"${LIGHTBLUE}mac dock:add-space ${LIGHTGREEN}N${GRAY}: Add blank space to dock - ${LIGHTGREEN}N = Number of spaces to add\"\n            echo \"${LIGHTBLUE}mac eject-all${GRAY}: Eject all mounted volumes and disks\"\n            echo \"${LIGHTBLUE}mac battery${GRAY}: Get battery information\"\n            echo \"${LIGHTBLUE}mac info${GRAY}: Get OS X version information\"\n            echo \"${LIGHTBLUE}mac find:text ${LIGHTGREEN}X${GRAY}: Find exact phrase recursively inside directory - ${LIGHTGREEN}X = Text string\"\n            echo \"${LIGHTBLUE}mac find:biggest-files ${GRAY}: Find biggest files inside directory\"\n            echo \"${LIGHTBLUE}mac find:biggest-directories ${GRAY}: Find biggest directories inside directory\"\n            echo \"${LIGHTBLUE}mac zip:extract ${LIGHTGREEN}X${GRAY}: Extract Zip file to current folder - ${LIGHTGREEN}X = Zip file to extract\"\n            echo \"${LIGHTBLUE}mac gzip:compress ${LIGHTGREEN}X${GRAY}: Compress current file using Gzip - ${LIGHTGREEN}X = File to compress\"\n            echo \"${LIGHTBLUE}mac gzip:extract ${LIGHTGREEN}X${GRAY}: Extract Gzip file to current folder - ${LIGHTGREEN}X = Gzip file to extract\"\n            echo \"${LIGHTBLUE}mac tar:compress ${LIGHTGREEN}X${GRAY}: Compress X file/directory using tar with progress indicator - ${LIGHTGREEN}X = File or directory\"\n            echo \"${LIGHTBLUE}mac tar:extract ${LIGHTGREEN}X${GRAY}: Extract tar file to current folder - ${LIGHTGREEN}X = Tar file to extract\"\n            echo \"${NC}\\n\"\n            ;;\n        search)\n            echo \"\\n${WHITEBOLD}Search Utilities: \"\n            echo \"${LIGHTBLUE}mac find:recent ${LIGHTGREEN}X${GRAY}: Find files modified in the last N minutes - ${LIGHTGREEN}X = number of minutes \"\n            echo \"${LIGHTBLUE}mac search:replace ${LIGHTGREEN}X${GRAY}: Search and replace string in file - ${LIGHTGREEN}X = File to perform the search and replace operation\"\n            echo \"${NC}\\n\"\n            ;;\n        network)\n            echo \"\\n${WHITEBOLD}Network Utilities: \"\n            echo \"${LIGHTBLUE}mac speedtest${GRAY}: Internet connection speed test \"\n            echo \"${LIGHTBLUE}mac ports${GRAY}: List of used ports \"\n            echo \"${LIGHTBLUE}mac ip:local${GRAY}: Get local IP address \"\n            echo \"${LIGHTBLUE}mac ip:public${GRAY}: Get public IP address \"\n            echo \"${NC}\\n\"\n            ;;\n        dns)\n            echo \"\\n${WHITEBOLD}DNS Utilities: \"\n            echo \"${LIGHTBLUE}mac dns:list${GRAY}: List DNS server(s) \"\n            echo \"${LIGHTBLUE}mac dns:add${GRAY}: Add DNS server \"\n            echo \"${LIGHTBLUE}mac dns:remove${GRAY}: Remove DNS server \"\n            echo \"${LIGHTBLUE}mac dns:flush${GRAY}: Flush DNS cache \"\n            echo \"${NC}\\n\"\n            ;;\n        ssh)\n            echo \"\\n${WHITEBOLD}SSH Utilities: \"\n            echo \"${LIGHTBLUE}mac ssh:download-file ${LIGHTGREEN}X${GRAY}: Download file from remote server through SSH - X = Path of the remote file to download \"\n            echo \"${LIGHTBLUE}mac ssh:download-folder ${LIGHTGREEN}X${GRAY}: Download entire folder from remote server through SSH - X = Path of the remote folder to download \"\n            echo \"${LIGHTBLUE}mac ssh:sync:local ${LIGHTGREEN}X${GRAY}: Sync local folder with remote folder using rsync through SSH (download remote folder to local folder)\"\n            echo \"${LIGHTBLUE}mac ssh:sync:remote ${LIGHTGREEN}X${GRAY}: Path of the remote folder to sync from local folder (upload local folder to remote folder) \"\n            echo \"${LIGHTBLUE}mac ssh:upload ${LIGHTGREEN}X${GRAY}: Upload file to remote server through SSH - X = Path of the file to upload to the remote server \"\n            echo \"${LIGHTBLUE}mac ssh:public-key ${LIGHTGREEN}X${GRAY}: Get public SSH key for local machine \"\n            echo \"${NC}\\n\"\n            ;;\n        performance)\n            echo \"\\n${WHITEBOLD}Performance and maintenance Utilities: \"\n            echo \"${LIGHTBLUE}mac system${GRAY}: Show system information to review mac performance \"\n            echo \"${LIGHTBLUE}mac temp${GRAY}: Show temperature, fan and battery statistics \"\n            echo \"${LIGHTBLUE}mac memory${GRAY}: See memory usage sorted by memory consumption \"\n            echo \"${LIGHTBLUE}mac trash:empty${GRAY}: Empty trash\"\n            echo \"${LIGHTBLUE}mac trash:size${GRAY}: Calculate trash size\"\n            echo \"${NC}\\n\"\n            ;;\n        git)\n            echo \"\\n${WHITEBOLD}Git Utilities: \"\n            echo \"${LIGHTBLUE}mac git:config${GRAY}: Display local Git configuration \"\n            echo \"${LIGHTBLUE}mac git:open${GRAY}: Open current repository on Github \"\n            echo \"${LIGHTBLUE}mac git:create:branch${GRAY}: Create branch based on current branch \"\n            echo \"${LIGHTBLUE}mac git:branches:date${GRAY}: Get last update date for all branches in current project \"\n            echo \"${LIGHTBLUE}mac git:undo-commit${GRAY}: Undo latest commit \"\n            echo \"${LIGHTBLUE}mac git:log${GRAY}: See latest commits IDs and titles for current branch \"\n            echo \"${LIGHTBLUE}mac git:branch${GRAY}: See all branches \"\n            echo \"${LIGHTBLUE}mac git:branch:rename${GRAY}: Rename Git branch \"\n            echo \"${LIGHTBLUE}mac git:branch:remove-local${GRAY}: Remove local Git branch \"\n            echo \"${LIGHTBLUE}mac git:branch:remove-remote${GRAY}: Remove local and remote Git branch \"\n            echo \"${LIGHTBLUE}mac git:branch${GRAY}: See all branches \"\n            echo \"${LIGHTBLUE}mac git:add-removed${GRAY}: Add removed files to staged files \"\n            echo \"${LIGHTBLUE}mac git:size${GRAY}: Get size for current Git repository \"\n            echo \"${NC}\\n\"\n            ;;\n        homebrew)\n            echo \"\\n${WHITEBOLD}Homebrew Utilities: \"\n            echo \"${LIGHTBLUE}mac brew:update${GRAY}: Upgrade Homebrew, installed Homebrew packages, and cleanup \"\n            echo \"${NC}\\n\"\n            ;;\n    esac\n\n}\n\n\ncase ${fn} in\n    \"list\"|\"help\"|\"usage\")\n        echo \"$(printInfo)\"\n        for c in ${MacCategories[@]}\n        do\n            echo \"$(usageList ${c})\"\n        done\n        echo \"$(printAdditionalHelp)\"\n        ;;\n    \"categories\")\n        echo \"$(printInfo)\"\n        echo \"\\n${WHITEBOLD}mac CLI Categories: ${NC}\\n\"\n        for c in \"${MacCategories[@]}\"\n        do\n            echo \"${WHITEBOLD} >\\t$c ${NC}\"\n        done\n        echo \"$(printAdditionalHelp)\"\n        ;;\nesac\n\nfor c in \"${MacCategories[@]}\"\ndo\n    if [ \"${c}\" = \"${fn}\" ]; then\n        echo \"$(printInfo)\"\n        echo \"\\n${WHITEBOLD}Usage for 'mac ${c}'\"\n        echo \"$(usageList ${c})\"\n        break\n    fi\ndone\n"
  },
  {
    "path": "mac-cli/plugins/brew",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# Homebrew Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # Update Homebrew and installed packages\n    \"brew:update\")\n        echo \"Updating Homebrew and its installed packages...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}brew update; brew upgrade;  brew upgrade --cask; brew cleanup;\\n${NC}\"\n        fi\n        brew update; brew upgrade;  brew upgrade --cask; brew cleanup;\n    ;;\n\nesac\n"
  },
  {
    "path": "mac-cli/plugins/dns",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# DNS Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # List DNS server(s)\n    \"dns:list\")\n        echo \"List of the DNS server(s):\"\n        cat /etc/resolv.conf | grep nameserver | cut -b 11-\n    ;;\n\n    # Add DNS server\n    \"dns:add\")\n        if [[ $2 =~ ^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$ ]]\n        then\n            echo \"Adding DNS server $2\"\n            sudo sh -c \"echo nameserver '${2}' >> /etc/resolv.conf\"\n        else\n            echo \"Please provide a valid DNS server address to add.\"\n            exit 1\n        fi\n    ;;\n\n    # Remove DNS server\n    \"dns:remove\")\n        if [[ $2 =~ ^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$ ]]\n        then\n            echo \"Deleting DNS server ${2}...\"\n            sudo sed -i \"\" \"/${2}/d\" /etc/resolv.conf\n        else\n            echo \"Please provide a valid DNS server address to remove.\"\n            exit 1\n        fi\n    ;;\n\n    # Flush DNS cache\n    \"dns:flush\")\n        VERSION=$(sw_vers -productVersion)\n        echo \"Flushing DNS cache...\"\n        if echo $VERSION | grep -E '^10\\.10(\\.[0-3])?$' >/dev/null 2>&1; then\n            sudo discoveryutil mdnsflushcache\n        elif echo $VERSION | grep -E '^10\\.6(\\.[0-8])?$' >/dev/null 2>&1; then\n            sudo dscacheutil -flushcache\n        else\n            sudo killall -HUP mDNSResponder\n        fi\n    ;;\n\nesac"
  },
  {
    "path": "mac-cli/plugins/general",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# General Variables\n#--------------------------------------------------------------------\n\n_W_DEVICE=${_W_DEVICE:-en0}\n\n#--------------------------------------------------------------------\n# General Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # Install macOS software updates, update installed Ruby gems, Homebrew, npm, pip and their installed packages\n    \"update\")\n\n        echo \"Updating macOS...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}sudo softwareupdate -i -a;\\n${NC}\"\n        fi\n        sudo softwareupdate -i -a;\n\n        echo \"Updating Homebrew and its installed packages...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}brew update; brew upgrade;  brew upgrade --cask; brew cleanup; \\n${NC}\"\n        fi\n        brew update; brew upgrade;  brew upgrade --cask; brew cleanup;\n\n        echo \"Updating npm and its installed packages...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}npm install npm -g; npm update -g;\\n${NC}\"\n        fi\n        npm install npm -g; npm update -g;\n\n        echo \"Updating Yarn's installed packages...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}yarn global upgrade;\\n${NC}\"\n        fi\n        yarn global upgrade;\n\n        echo \"Updating installed Ruby gems...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}sudo gem update --system; sudo gem update\\n${NC}\"\n        fi\n        sudo gem update --system; sudo gem update\n\n        echo \"Updating installed pip packages...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}pip list --outdated --local | tail -n +3 | awk '{print \\$1}' | xargs -n1 pip install -U\\n${NC}\"\n        fi\n        pip list --outdated --local | tail -n +3 | awk '{print $1}' | xargs -n1 pip install -U\n\n        if [ -x \"$(command -v pip3)\" ]; then\n            echo \"Updating installed pip3 packages...\"\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}pip3 list --outdated --local | tail -n +3 | awk '{print \\$1}' | xargs -n1 pip3 install -U\\n${NC}\"\n            fi\n            pip3 list --outdated --local | tail -n +3 | awk '{print $1}' | xargs -n1 pip3 install -U\n        fi\n\n        if [ -f /usr/local/bin/apm ]; then\n            echo \"Updating Atom Packages...\"\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}apm upgrade --no-confirm\\n${NC}\"\n            fi\n            apm upgrade --no-confirm\n        fi\n    ;;\n\n\n    # Upgrade Mac CLI to the latest version\n    \"upgrade\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}sh -c \"$(curl -fsSL https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/update)\"\\n\\n${NC}\"\n        fi\n        sh -c \"$(curl -fsSL https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/update)\"\n    ;;\n\n\n    # Uninstall Mac CLI from your Mac\n    \"uninstall\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}sh -c \"$(curl -fsSL https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/uninstall)\"\\n\\n${NC}\"\n        fi\n        sh -c \"$(curl -fsSL https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/uninstall)\"\n    ;;\n\n\n    # Get macOS Info\n    \"info\")\n        printf \"${GREEN}sw_vers\\n${NC}\"\n        sw_vers\n    ;;\n\n\n    # Lock Mac\n    \"lock\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend\\n\\n${NC}\"\n        fi\n        /System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend\n    ;;\n\n\n    # Restart Mac\n    \"restart\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}osascript -e 'tell app 'loginwindow' to «event aevtrrst»''\\n\\n${NC}\"\n        fi\n        osascript -e 'tell app \"loginwindow\" to «event aevtrrst»'\n    ;;\n\n\n    # Sleep\n    \"sleep\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}pmset sleepnow\\n\\n${NC}\"\n        fi\n        pmset sleepnow\n    ;;\n\n\n    # Shutdown Mac\n    \"shutdown\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}osascript -e 'tell app 'loginwindow' to «event aevtrsdn»'\\n\\n${NC}\"\n        fi\n        osascript -e 'tell app \"loginwindow\" to «event aevtrsdn»'\n    ;;\n\n    # Uptime\n    \"uptime\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}uptime\\n\\n${NC}\"\n        fi\n        uptime\n    ;;\n\n\n    #List folders in current directory\n    \"folders:list\")\n        du -sk * | sort -rn\n    ;;\n\n\n    # Calculate folder size\n    \"folder:size\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}du -sh .\\n\\n${NC}\"\n        fi\n        echo \"Calculating folder size...\"\n        echo \"Folder size:\"\n        du -sh .\n    ;;\n\n\n    # Show hidden files\n    \"hidden:show\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}defaults write com.apple.finder AppleShowAllFiles YES; killall Finder\\n\\n${NC}\"\n        fi\n        defaults write com.apple.finder AppleShowAllFiles YES; killall Finder\n    ;;\n\n\n    # Hide hidden files\n    \"hidden:hide\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}defaults write com.apple.finder AppleShowAllFiles NO; killall Finder\\n\\n${NC}\"\n        fi\n        defaults write com.apple.finder AppleShowAllFiles NO; killall Finder\n    ;;\n\n\n    # Check bluetooth status\n    \"bluetooth:status\")\n        defaults read /Library/Preferences/com.apple.Bluetooth ControllerPowerState | \\\n            awk '{ if($1 != 0) {print \"Bluetooth: ON\"} else { print \"Bluetooth: OFF\" }  }'\n    ;;\n\n\n    # Enable bluetooth\n    \"bluetooth:enable\")\n        echo \"${GREEN}Bluetooth enabled{NC}\"\n        sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 1 && \\\n            sudo killall -HUP bluetoothd\n    ;;\n\n\n    # Disable bluetooth\n    \"bluetooth:disable\")\n        echo \"${GREEN}Bluetooth disabled${NC}\"\n        sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0 && \\\n            sudo killall -HUP bluetoothd\n    ;;\n\n\n    # Check wifi status\n    \"wifi:status\")\n        /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I\n    ;;\n\n\n    # Check available wifi networks\n    \"wifi:scan\")\n        /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s\n    ;;\n\n\n    # Enable wifi\n    \"wifi:enable\")\n        echo \"${GREEN}Wifi enabled${NC}\"\n        networksetup -setairportpower ${_W_DEVICE} on\n    ;;\n\n\n    # Disable wifi\n    \"wifi:disable\")\n        echo \"${GREEN}Wifi disabled${NC}\"\n        networksetup -setairportpower ${_W_DEVICE} off\n    ;;\n\n\n    # Add blank space to the dock\n    \"dock:add-space\")\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n          echo \"${GREEN}Added $firstParameter new blank spaces to the dock${NC}\"\n\n          for i in `seq \"$firstParameter\"`; do\n            defaults write com.apple.dock persistent-apps -array-add '{\"tile-type\"=\"spacer-tile\";}'\n          done\n        else\n          echo \"${GREEN}Added new blank space to the dock${NC}\"\n          defaults write com.apple.dock persistent-apps -array-add '{\"tile-type\"=\"spacer-tile\";}'\n        fi\n\n        killall Dock\n    ;;\n\n\n    # Start screensaver\n    \"screensaver\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}open -a ScreenSaverEngine\\n\\n${NC}\"\n        fi\n        open -a ScreenSaverEngine\n    ;;\n\n\n    # Eject all mounted volumes and disk\n    \"eject-all\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}osascript -e 'tell application 'Finder' to eject (every disk whose ejectable is true)'\\n\\n${NC}\"\n        fi\n        osascript -e 'tell application \"Finder\" to eject (every disk whose ejectable is true)'\n    ;;\n\n\n    # Get battery information\n    \"battery\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}pmset -g batt\\n\\n${NC}\"\n        fi\n        pmset -g batt\n    ;;\n\n\n    # Find text in current directory\n    \"find:text\")\n\n        if [ ! -z \"$allParameters\" -a \"$allParameters\" != \" \" ]; then\n            echo \"Please enter the extension to search (i.e.: csv): \"\n\n            read extension\n\n            if [ ! -z \"$extension\" -a \"$extension\" != \" \" ]; then\n\n                if [ \"$echocommand\" == \"true\" ]; then\n                    echo \"${GREEN}find . -iname '*.${GRAY}${extension}${GREEN}' | xargs grep -in --color '${GRAY}${allParameters}${GREEN}'${NC}\"\n                fi\n                echo \"\\nRecursively find '\"$allParameters\"' inside directory...\"\n                find . -iname \"*.$extension\" | xargs grep -in --color \"$allParameters\"\n\n            else\n                echo \"Please introduce the extension of the files to search. E.g: csv\"\n            fi\n        else\n            echo \"Please introduce text to search. E.g:\"\n            echo \"mac find:text Sample Search Text\"\n        fi\n    ;;\n\n\n    # Find biggest files in current directory\n    \"find:biggest-files\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}${NC}\"\n        fi\n        find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}\n    ;;\n\n\n    # Find biggest directories in current directory\n    \"find:biggest-directories\")\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}${NC}\"\n        fi\n        find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}\n    ;;\n\n\n    # Extract Zip file\n    \"zip:extract\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}unzip ${GRAY}${firstParameter}\\n\\n${NC}\"\n            fi\n            unzip $firstParameter\n        else\n            echo \"Please specify the Zip file to extract.\"\n            echo \"E.g.: zip:extract sample_file.zip\"\n        fi\n    ;;\n\n\n    # Compress Gzip file\n    \"gzip:compress\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}gzip ${GRAY}${firstParameter}\\n\\n${NC}\"\n            fi\n            gzip $firstParameter\n        else\n            echo \"Please specify the file to compress.\"\n            echo \"E.g.: gzip:compress sample_file\"\n        fi\n    ;;\n\n\n    # Extract Gzip file\n    \"gzip:extract\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}gzip -d ${GRAY}${firstParameter}\\n\\n${NC}\"\n            fi\n            gzip -d $firstParameter\n        else\n            echo \"Please specify the Gzip file to extract.\"\n            echo \"E.g.: gzip:extract sample_file.gz\"\n        fi\n    ;;\n\n\n    # Extract tar file\n    \"tar:extract\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}tar -xvzf ${GRAY}${firstParameter}\\n\\n${NC}\"\n            fi\n            tar -xvzf $firstParameter\n        else\n            echo \"Please specify the tar file to extract.\"\n            echo \"E.g.: tar:extract sample_file.tgz\"\n\t    fi\n    ;;\n\n\n    # Compress file/folder using TAR with progress indicator\n    \"tar:compress\")\n        echo \"Please enter the filename to save the .tgz file: \"\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            read filename\n\n            if [ ! -z \"$filename\" -a \"$filename\" != \" \" ]; then\n                if [ \"$echocommand\" == \"true\" ]; then\n                    echo \"${GREEN}tar -czf${GRAY}: ${firstParameter}${GREEN}  | (pv -p --timer --rate --bytes > '${GRAY}${filename}${GREEN}'.tgz)\\n\\n${NC}\"\n                fi\n                tar -czf - $firstParameter | (pv -p --timer --rate --bytes > \"$filename\".tgz)\n            else\n                \"Please specify the file name\"\n            fi\n        else\n            echo \"Please specify the folder or directory to compress.\"\n            echo \"E.g.: tar:compress foldername\"\n        fi\n    ;;\n\n\n    # Search and replace string on file\n    \"search:replace\")\n        echo \"Please enter the string to search on the file:\"\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            read searchString\n\n            if [ ! -z \"$searchString\" -a \"$searchString\" != \" \" ]; then\n\n                echo \"Please enter the string that will replace the search string:\"\n                read replaceString\n\n                if [ ! -z \"$replaceString\" -a \"$replaceString\" != \" \" ]; then\n\n                    if [ \"$echocommand\" == \"true\" ]; then\n                        echo \"${GREEN}LC_CTYPE=C sed -i'' -e 's#${GRAY}${searchString}${GREEN}#${GRAY}${replaceString}${GREEN}#g' ${GRAY}${firstParameter}\\n\\n${NC}\"\n                    fi\n                    LC_CTYPE=C sed -i'' -e 's#'\"${searchString}\"'#'\"${replaceString}\"'#g' $firstParameter\n\n                else\n                    \"Please specify the string to replace\"\n                fi\n\n            else\n                \"Please specify the string to search\"\n            fi\n        else\n            echo \"Please specify the file to perform the search and replace operation\"\n            echo \"E.g.: search:replace /path/to/file.csv\"\n        fi\n    ;;\n\n\nesac\n"
  },
  {
    "path": "mac-cli/plugins/git",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# Git Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # Display local Git configuration\n    \"brew:git:config\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}git config --list\\n\\n${NC}\"\n        fi\n        git config --list\n    ;;\n\n\n    # Open current Git repository on Github\n    \"git:open\")\n\n        giturl=$(git config --get remote.origin.url)\n          if [ \"$giturl\" == \"\" ]\n            then\n             echo \"Not a git repository or no remote.origin.url set\"\n             exit 1;\n          fi\n          giturl=${giturl/git\\@github\\.com\\:/https://github.com/}\n          giturl=${giturl/\\.git/\\/}\n          branch=\"$(git symbolic-ref HEAD 2>/dev/null)\" ||\n          branch=\"(unnamed branch)\"     # detached HEAD\n          branch=${branch##refs/heads/}\n          giturl=$giturl\n          open $giturl\n    ;;\n\n\n    # Create Git branch based on current branch\n    \"git:create:branch\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}git checkout -b ${GRAY}$firstParameter\\n\\n${NC}\"\n            fi\n            git checkout -b $firstParameter\n\n        else\n            echo \"Please specify the name for the new branch\"\n            echo \"E.g.: git:create:branch sample-branch\"\n        fi\n    ;;\n\n\n    # Get last update date for all branches in current project\n    \"git:branches\")\n\n        git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'\n    ;;\n\n\n    # Undo latest commit\n    \"git:undo-commit\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}git reset --soft HEAD~\\n\\n${NC}\"\n        fi\n        git reset --soft HEAD~\n    ;;\n\n\n    # See latest commits IDs and titles for current branch\n    \"git:log\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}git log --pretty=oneline\\n\\n${NC}\"\n        fi\n    \tgit log --pretty=oneline\n    ;;\n\n\n    # See all branches\n    \"git:branch\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}git branch -a\\n\\n${NC}\"\n        fi\n        git branch -a\n    ;;\n\n\n    # Rename Git branch\n    \"git:branch:rename\")\n\n         if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}git branch -m ${GRAY}$firstParameter\\n\\n${NC}\"\n            fi\n            git branch -m $firstParameter\n\n        else\n            echo \"Please specify the name of the branch to rename\"\n            echo \"E.g.: git:branch:rename sample-branch\"\n        fi\n    ;;\n\n\n    # Remove local Git branch\n    \"git:branch:remove-local\")\n\n         if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}git branch -d ${GRAY}$firstParameter\\n\\n${NC}\"\n            fi\n            git branch -d $firstParameter\n\n        else\n            echo \"Please specify the name of the branch to remove\"\n            echo \"E.g.: git:branch:remove-local sample-branch\"\n        fi\n    ;;\n\n\n    # Remove local and remote Git branch\n    \"git:branch:remove-remote\")\n\n         if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}git branch -d ${GRAY}$firstParameter\\n\\n${NC}\"\n            fi\n            git branch -d $firstParameter\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}git push origin --delete ${GRAY}$firstParameter\\n\\n${NC}\"\n            fi\n            git push origin --delete $firstParameter\n\n        else\n            echo \"Please specify the name of the branch to remove\"\n            echo \"E.g.: git:branch:remove-remote sample-branch\"\n        fi\n    ;;\n\n\n    # Check Git settings\n    \"git:config\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}git config --list\\n\\n${NC}\"\n        fi\n        git config --list\n    ;;\n\n\n    # Add removed files to staged files\n    \"git:add-removed\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}git add -u\\n\\n${NC}\"\n        fi\n        git add -u\n    ;;\n\n\n    # Open current Git repository URL\n    \"git:open\")\n\n        open `git remote -v | awk '/fetch/{print $2}' | sed -Ee 's#(git@|git://)#http://#' -e 's@com:@com/@'`| head -n1\n    ;;\n\n\n    # Get size of current Git repository\n    \"git:size\")\n\n        git bundle create tmp.bundle --all\n        echo \"\\n\\nCurrent Git repository size: \"\n        du -sh tmp.bundle\n        rm tmp.bundle\n    ;;\n\n\nesac"
  },
  {
    "path": "mac-cli/plugins/network",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# Network Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # Internet connection speed test\n    \"speedtest\")\n          echo \"Testing internet connection speed...\"\n          networkQuality -v\n    ;;\n\n\n    # List of used ports\n    \"ports\")\n\n        echo \"Getting list of used ports...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}sudo lsof -iTCP -sTCP:LISTEN -P\\n\\n${NC}\"\n        fi\n        sudo lsof -iTCP -sTCP:LISTEN -P\n    ;;\n\n\n    # Get local IP address\n    \"ip:local\")\n\n        local_ip=$(ipconfig getifaddr en0)\n        if [ $? == 0 ]; then\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}ipconfig getifaddr en0\\n\\n${NC}\"\n            fi\n        else\n            if [ \"$echocommand\" == \"true\" ]; then\n                echo \"${GREEN}ipconfig getifaddr en1\\n\\n${NC}\"\n            fi\n            local_ip=$(ipconfig getifaddr en1)\n        fi\n        echo \"Your IP address is:\\n${local_ip}\"\n    ;;\n\n\n    # Get public IP address\n    \"ip:public\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}wget http://ipinfo.io/ip -qO -\\n\\n${NC}\"\n        fi\n        wget http://ipinfo.io/ip -qO -\n    ;;\n\nesac\n"
  },
  {
    "path": "mac-cli/plugins/performance",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# Performance and maintenance Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # See memory usage sorted by memory consumption\n    \"memory\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}top -o MEM \\n\\n${NC}\"\n        fi\n        top -o MEM\n    ;;\n\n\n    # Empty trash\n    \"trash:empty\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}sudo rm -rf ~/.Trash/* \\n\\n${NC}\"\n        fi\n        sudo rm -rf ~/.Trash/*\n    ;;\n\n\n    # Calculate trash size\n    \"trash:size\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}du -sh ~/.Trash/ \\n\\n${NC}\"\n        fi\n        echo \"Trash size: \"\n        du -sh ~/.Trash/\n    ;;\n\nesac"
  },
  {
    "path": "mac-cli/plugins/search",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# Search Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # Find files modified in the last N minutes\n    \"find:recent\")\n\n        echo \"Searching for files modified in the last \"$firstParameter\" minutes...\"\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}sudo find / -mmin ${GRAY}${firstParameter}${GREEN} -type f\\n\\n${NC}\"\n        fi\n        sudo find / -mmin $firstParameter -type f\n    ;;\n\nesac"
  },
  {
    "path": "mac-cli/plugins/ssh",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# SSH Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # Download file through SSH on current folder\n    \"ssh:download-file\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n\n            echo \"Please enter the server IP address or domain: \"\n\n            read ipaddress\n            if [ ! -z \"$ipaddress\" -a \"$ipaddress\" != \" \" ]; then\n\n                echo \"Please enter username: \"\n\n                read username\n\n                if [ ! -z \"$username\" -a \"$username\" != \" \" ]; then\n\n                    if [ \"$echocommand\" == \"true\" ]; then\n                        echo \"${GREEN}scp ${GRAY}${username}@${ipaddress}:${firstparameter}${GREEN} .\\n\\n${NC}\"\n                    fi\n                    scp $username@$ipaddress:$firstParameter .\n\n                else\n                    \"Please specify the username for the remote server\"\n                fi\n\n            else\n                \"Please specify the server IP address or domain\"\n            fi\n\n        else\n            echo \"Please specify the path to the file on the remote server to download\"\n            echo \"E.g.: /home/sample/file.jpg\"\n        fi\n    ;;\n\n\n    # Download entire folder through SSH on current directory\n    \"ssh:download-folder\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n\n            echo \"Please enter the server IP address or domain: \"\n\n            read ipaddress\n            if [ ! -z \"$ipaddress\" -a \"$ipaddress\" != \" \" ]; then\n\n                echo \"Please enter username: \"\n\n                read username\n\n                if [ ! -z \"$username\" -a \"$username\" != \" \" ]; then\n\n                    if [ \"$echocommand\" == \"true\" ]; then\n                        echo \"${GREEN}scp -r ${GRAY}${username}@${ipaddress}:${firstparameter}${GREEN} .\\n\\n${NC}\"\n                    fi\n                    scp -r $username@$ipaddress:$firstParameter .\n\n                else\n                    \"Please specify the username for the remote server\"\n                fi\n\n            else\n                \"Please specify the server IP address or domain\"\n            fi\n\n        else\n            echo \"Please specify the path to the folder on the remote server to download\"\n            echo \"E.g.: /home/sample/folder/\"\n        fi\n    ;;\n\n\n    # Sync local folder with remote folder using rsync through SSH (download remote folder to local folder)\n    \"ssh:sync:local\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n\n            echo \"Please enter the server IP address or domain: \"\n\n            read ipaddress\n            if [ ! -z \"$ipaddress\" -a \"$ipaddress\" != \" \" ]; then\n\n                echo \"Please enter username: \"\n\n                read username\n\n                if [ ! -z \"$username\" -a \"$username\" != \" \" ]; then\n\n                    echo \"Please enter local folder to sync with the remote folder: \"\n\n                    read localfolder\n\n                    if [ ! -z \"$localfolder\" -a \"$localfolder\" != \" \" ]; then\n                        if [ \"$echocommand\" == \"true\" ]; then\n                            echo \"${GREEN}rsync -a --progress ${GRAY}${username}@${ipaddress}:${firstparameter} ${localfolder}${GREEN}\\n\\n${NC}\"\n                        fi\n                        rsync -a --progress ${username}@${ipaddress}:${firstparameter} ${localfolder}\n\n                    else\n                        \"Please specify the local folder to sync with the remote folder\"\n                    fi\n                else\n                    \"Please specify the username for the remote server\"\n                fi\n\n            else\n                \"Please specify the server IP address or domain\"\n            fi\n\n        else\n            echo \"Please specify the remote folder path to sync\"\n            echo \"E.g.: mac ssh:sync:remote /var/www/html/media/\"\n        fi\n    ;;\n\n\n    # Sync remote folder with local folder using rsync through SSH (upload local folder to remote folder)\n    \"ssh:sync:remote\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n\n            echo \"Please enter the server IP address or domain: \"\n\n            read ipaddress\n            if [ ! -z \"$ipaddress\" -a \"$ipaddress\" != \" \" ]; then\n\n                echo \"Please enter username: \"\n\n                read username\n\n                if [ ! -z \"$username\" -a \"$username\" != \" \" ]; then\n\n                    echo \"Please enter local folder to sync from the remove folder: \"\n\n                    read localfolder\n\n                    if [ ! -z \"$localfolder\" -a \"$localfolder\" != \" \" ]; then\n                        if [ \"$echocommand\" == \"true\" ]; then\n                            echo \"${GREEN}rsync -a ${localfolder} ${username}@${ipaddress}:${firstparameter}\\n\\n${NC}\"\n                        fi\n                        rsync -a --progress ${localfolder} ${username}@${ipaddress}:${firstparameter}\n\n                    else\n                        \"Please specify the local folder to sync from the remote folder\"\n                    fi\n                else\n                    \"Please specify the username for the remote server\"\n                fi\n\n            else\n                \"Please specify the server IP address or domain\"\n            fi\n\n        else\n            echo \"Please specify the remote folder path to sync\"\n            echo \"E.g.: mac ssh:sync:remote /var/www/html/media/\"\n        fi\n    ;;\n\n\n    # Upload file to remote server through SSH\n    \"ssh:upload\")\n\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n\n            echo \"Please enter the server IP address or domain: \"\n\n            read ipaddress\n\n            if [ ! -z \"$ipaddress\" -a \"$ipaddress\" != \" \" ]; then\n\n                echo \"Please enter username: \"\n\n                read username\n\n                if [ ! -z \"$username\" -a \"$username\" != \" \" ]; then\n\n                        echo \"Please enter path on the remote server to upload the file: \"\n\n                        read remotePath\n\n                        if [ ! -z \"$remotePath\" -a \"$remotePath\" != \" \" ]; then\n\n                            if [ \"$echocommand\" == \"true\" ]; then\n                                echo \"${GREEN}scp ${GRAY}${firstParameter} ${username}@${ipaddress}:${remotePath}${GREEN}\\n\\n${NC}\"\n                            fi\n                            scp $firstParameter $username@$ipaddress:$remotePath\n\n                        else\n                            \"Please specify the path on the remote server to upload the file\"\n                        fi\n\n                else\n                    \"Please specify the username for the remote server\"\n                fi\n\n            else\n                \"Please specify the server IP address or domain\"\n            fi\n\n        else\n            echo \"Please specify the path to the file to upload to the remote server\"\n            echo \"E.g.: /user/example/documents/file.pdf\"\n        fi\n    ;;\n\n\n    # SSH key Utilities\n    \"ssh:public-key\")\n\n        if [ \"$echocommand\" == \"true\" ]; then\n            echo \"${GREEN}pbcopy < ~/.ssh/id_rsa.pub \\n\\n${NC}\"\n        fi\n        pbcopy < ~/.ssh/id_rsa.pub\n    ;;\n\n\nesac"
  },
  {
    "path": "mac-cli/plugins/volume",
    "content": "#!/bin/sh\n\n#--------------------------------------------------------------------\n# Volume Utilities\n#--------------------------------------------------------------------\n\ncase \"$fn\" in\n\n    # Get current volume\n    \"volume\")\n        if [ ! -z \"$firstParameter\" -a \"$firstParameter\" != \" \" ]; then\n            osascript -e \"set volume output volume $firstParameter\"\n            echo \"${WHITEBOLD}Vol:${NC} ${GREEN}${firstParameter}%${NC}\"\n        else\n            echo \"${WHITEBOLD}Vol:${NC} ${GREEN}$(osascript -e \"output volume of (get volume settings)\")% ${NC}\"\n\n        fi\n    ;;\n\n     # Is volume muted?\n    \"volume:ismute\")\n        echo \"${WHITEBOLD}Mute:${NC} ${GREEN}$(osascript -e 'output muted of (get volume settings)')${NC}\"\n    ;;\n\n     # Mute volume\n    \"volume:mute\")\n        osascript -e \"set volume output muted true\"\n        echo \"${WHITEBOLD}Mute:${NC} ${GREEN}true${NC}\"\n    ;;\n\n     # Unmute volume\n    \"volume:unmute\")\n        osascript -e \"set volume output muted false\"\n        echo \"${WHITEBOLD}Mute:${NC} ${GREEN}false${NC}\"\n    ;;\n\nesac\n"
  },
  {
    "path": "mac-cli/tools/install",
    "content": "#!/bin/sh\n\n# Colors\nGREEN='\\033[0;32m'\nLIGHTGREEN='\\033[1;32m'\nNC='\\033[1;37m'\nLIGHTBLUE='\\033[01;34m'\nNC='\\033[0m' # No Color\n\n# In directory\nPACKAGE_DIRECTORY=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nsuggest_current(){\n    case \"$1\" in\n        \"editor\")\n            current=$EDITOR\n        ;;\n        *)\n            current=$(which $1)\n        ;;\n    esac\n    if [ -n $current ]; then\n        echo $current | pbcopy\n        echo \"${NC}Press ⌘V to insert current (${current})\"\n    fi\n}\n\nmain() {\n\n    echo \"${LIGHTBLUE}================================================\"\n    echo \" Mac CLI Installer\"\n    echo \"================================================${NC}\\n\"\n\n    git clone https://github.com/guarinogabriel/mac-cli.git --depth 1 && cd mac-cli\n\n    printf \"${LIGHTGREEN}\"\n    read -r -p \"Would you like Mac CLI to show you the commands that are run on each mac command? (Yes / No)\" response\n    case $response in\n        [yY][eE][sS]|[yY])\n            LC_CTYPE=C sed -i'' -e 's#echocommand=\"false\"#echocommand=\"true\"#g' \"$PACKAGE_DIRECTORY/mac-cli/mac\"\n            ;;\n        *)\n            ;;\n    esac\n    printf \"${NC}\"\n\n    sudo cp \"$PACKAGE_DIRECTORY/mac-cli/mac\" /usr/local/bin/mac\n    sudo cp -r \"$PACKAGE_DIRECTORY/mac-cli/mac-cli/\" /usr/local/bin/mac-cli\n    sudo chmod -R +x /usr/local/bin/mac-cli/*\n\n    if ! [ -x \"$(command -v brew)\" ]; then\n        echo \"Installing Homebrew...\"\n        echo \"${GREEN}/usr/bin/ruby -e '\\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'\\n${NC}\"\n        /usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n    fi\n\n    if ! [ -x \"$(command -v git)\" ]; then\n        echo \"Installing Git...\"\n        echo \"${GREEN}brew install git\\n${NC}\"\n        brew install git\n\t  fi\n\n    if ! [ -x \"$(command -v pv)\" ]; then\n        echo \"Installing pv (Pipe Viewer)...\"\n        echo \"${GREEN}brew install pv\\n${NC}\"\n        brew install pv\n\t  fi\n\n    if ! [ -x \"$(command -v wget)\" ]; then\n        echo \"Installing wget...\"\n        printf \"${GREEN}brew install wget\\n${NC}\"\n        brew install wget\n\t  fi\n\n    if ! brew list | grep -q bash-completion ; then\n\n            echo \"Installing bash-completion\\n\"\n            echo \"${GREEN}brew install bash-completion\\n\\n${NC}\"\n            brew install bash-completion\n            echo 'if [ -f $(brew --prefix)/etc/bash_completion ]; then source $(brew --prefix)/etc/bash_completion; fi' >> ~/.bashrc\n            echo \"Setting up Mac-CLI bash-completion\\n\"\n\n        if [ -d /usr/local/etc/bash_completion.d/ ]; then\n            cp /usr/local/bin/mac-cli/completion/bash_completion /usr/local/etc/bash_completion.d/mac\n        fi\n\n    else\n\n        echo \"Setting up Mac-CLI bash-completion\\n\"\n\n        if [ -d $(brew --prefix)/etc/bash_completion.d/ ]; then\n            cp /usr/local/bin/mac-cli/completion/bash_completion $(brew --prefix)/etc/bash_completion.d/mac\n            echo 'if [ -f $(brew --prefix)/etc/bash_completion ]; then source $(brew --prefix)/etc/bash_completion; fi' >> ~/.bashrc\n        fi\n\n    fi\n\n    #\n    # Check if fish shell is installed and prompt user to copy fish_completion\n    #\n    if $(cat /etc/shells | grep -q fish) && [ -d ~/.config/fish ];\n    then\n\t    printf \"${LIGHTGREEN}\"\n\t    read -r -p \"Would you like to install fish shell suggestions/tab completion? (Yes / No) \" response\n\t    case $response in\n\t\t    [yY][eE][sS]|[yY])\n\t\t\t    echo \"Setting up Mac-CLI Fish completion\"\n\t\t\t    if [ -d ~/.config/fish/completions ];then\n\t\t\t\t    cp /usr/local/bin/mac-cli/completion/fish_completion ~/.config/fish/completions/mac.fish\n\t\t\t    else\n\t\t\t\t    mkdir ~/.config/fish/completions && cp /usr/local/bin/mac-cli/completion/fish_completion ~/.config/fish/completions/mac.fish\n\t\t\t    fi\n\t\t\t    ;;\n\t\t    *)\n\t\t\t    ;;\n\t    esac\n\t    printf \"${NC}\"\n    fi\n}\n\nmain\n"
  },
  {
    "path": "mac-cli/tools/uninstall",
    "content": "#!/bin/sh\n\nGREEN='\\033[0;32m'\nNC='\\033[0m' # No Color\n\nmain() {\n  echo \"Uninstalling Mac CLI...\"\n\trm /usr/local/bin/mac\n\trm -rf /usr/local/bin/mac-cli\n\techo \"${GREEN}Mac CLI has been uninstalled\\n${NC}\"\n}\n\nmain"
  },
  {
    "path": "mac-cli/tools/update",
    "content": "#!/bin/sh\n\nGREEN='\\033[0;32m'\nNC='\\033[0m' # No Color\n\nmain() {\n  echo \"Upgrading Mac CLI...\"\n\trm /usr/local/bin/mac\n\trm -rf /usr/local/bin/mac-cli\n\tif [ -d ~/Downloads/mac-cli-update/ ]; then\n\t    rm -rf ~/Downloads/mac-cli-update/\n\tfi\n\tmkdir ~/Downloads/mac-cli-update/ && cd ~/Downloads/mac-cli-update/\n\tsh -c \"$(curl -fsSL https://raw.githubusercontent.com/guarinogabriel/mac-cli/master/mac-cli/tools/install)\" && cd -\n\techo \"${GREEN}Mac CLI has been updated to the latest version\\n${NC}\"\n}\n\nmain"
  }
]