[
  {
    "path": ".gitattributes",
    "content": "# Force text files to have unix eols, so Windows/Cygwin does not break them\n*.* eol=lf\n\n# These files are unfortunately not recognized as text files so\n# explicitly listing them here\ntpm eol=lf\nbin/* eol=lf\nbindings/* eol=lf\ntests/* eol=lf\n"
  },
  {
    "path": ".gitignore",
    "content": "**/.vagrant/\nrun_tests\ntests/run_tests_in_isolation\ntests/helpers/helpers.sh\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"lib/tmux-test\"]\n\tpath = lib/tmux-test\n\turl = https://github.com/tmux-plugins/tmux-test.git\n"
  },
  {
    "path": ".travis.yml",
    "content": "# generic packages and tmux\nbefore_install:\n  - sudo apt-get update\n  - sudo apt-get install -y git-core expect\n  - sudo apt-get install -y python-software-properties software-properties-common\n  - sudo apt-get install -y libevent-dev libncurses-dev\n  - git clone https://github.com/tmux/tmux.git\n  - cd tmux\n  - git checkout 2.0\n  - sh autogen.sh\n  - ./configure && make && sudo make install\n\ninstall:\n  - git fetch --unshallow --recurse-submodules || git fetch --recurse-submodules\n  # manual `git clone` required for testing `tmux-test` plugin itself\n  - git clone https://github.com/tmux-plugins/tmux-test lib/tmux-test; true\n  - lib/tmux-test/setup\n\nscript: ./tests/run_tests_in_isolation\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\n### master\n\n### v3.1.0, 2023-01-03\n- upgrade to new version of `tmux-test`\n- bug: when using `emacs` copy mode, Enter does not quit screen after tpm\n  installation/update. Fix by making `Escape` the key for emacs mode.\n- add a doc with troubleshooting instructions\n- add `.gitattributes` file that forces linefeed characters (classic `\\n`) as\n  line endings - helps with misconfigured git on windows/cygwin\n- readme update: announce Cygwin support\n- un-deprecate old plugin definition syntax: `set -g @tpm_plugins`\n- More stuff, check `git log`.\n\n### v3.0.0, 2015-08-03\n- refactor `shared_set_tpm_path_constant` function\n- move all instructions to `docs/` dir\n- add `bin/install_plugins` cli executable script\n- improved test runner function\n- switch to using [tmux-test](https://github.com/tmux-plugins/tmux-test)\n  framework\n- add `bin/update_plugins` cli executable script\n- refactor test `expect` scripts, make them simpler and ensure they properly\n  assert expectations\n- refactor code that sets 'TMUX_PLUGIN_MANAGER_PATH' global env var\n- stop using global variable for 'tpm path'\n- support defining plugins via `set -g @plugin` in sourced files as well\n\n### v2.0.0, 2015-07-07\n- enable overriding default key bindings\n- start using `C-c` to clear screen\n- add uninstall/clean procedure and keybinding (prefix+alt+u) (@chilicuil)\n- add new `set @plugin 'repo'` plugin definition syntax (@chilicuil)\n- revert back to using `-g` flag in new plugin definition syntax\n- permit leading whitespace with new plugin definition syntax (thanks @chilicuil)\n- make sure `TMUX_PLUGIN_MANAGER_PATH` always has trailng slash\n- ensure old/deprecated plugin syntax `set -g @tpm_plugins` works alongside new\n  `set -g @plugin` syntax\n\n### v1.2.2, 2015-02-08\n- set GIT_TERMINAL_PROMPT=0 when doing `git clone`, `pull` or `submodule update`\n  to ensure git does not prompt for username/password in any case\n\n### v1.2.1, 2014-11-21\n- change the way plugin name is expanded. It now uses the http username\n  and password by default, like this: `https://git::@github.com/`. This prevents\n  username and password prompt (and subsequently tmux install hanging) with old\n  git versions. Fixes #7.\n\n### v1.2.0, 2014-11-20\n- refactor tests so they can be used on travis\n- add travis.yml, add travis badge to the readme\n\n### v1.1.0, 2014-11-19\n- if the plugin is not downloaded do not source it\n- remove `PLUGINS.md`, an obsolete list of plugins\n- update readme with instructions about uninstalling plugins\n- tilde char and `$HOME` in `TMUX_SHARED_MANAGER_PATH` couldn't be used because\n  they are just plain strings. Fixing the problem by manually expanding them.\n- bugfix: fragile `*.tmux` file globbing (@majutsushi)\n\n### v1.0.0, 2014-08-05\n- update readme because of github organization change to\n  [tmux-plugins](https://github.com/tmux-plugins)\n- update tests to pass\n- update README to suggest different first plugin\n- update list of plugins in the README\n- remove README 'about' section\n- move key binding to the main file. Delete `key_binding.sh`.\n- rename `display_message` -> `echo_message`\n- installing plugins installs just new plugins. Already installed plugins aren't\n  updated.\n- add 'update plugin' binding and functionality\n- add test for updating a plugin\n\n### v0.0.2, 2014-07-17\n- run all *.tmux plugin files as executables\n- fix all redirects to /dev/null\n- fix bug: TPM shared path is created before sync (cloning plugins from github\n  is done)\n- add test suite running in Vagrant\n- add Tmux version check. `TPM` won't run if Tmux version is less than 1.9.\n\n### v0.0.1, 2014-05-21\n- get TPM up and running\n"
  },
  {
    "path": "HOW_TO_PLUGIN.md",
    "content": "Instructions moved to\n[docs/how_to_create_plugin.md](docs/how_to_create_plugin.md).\n"
  },
  {
    "path": "LICENSE.md",
    "content": "MIT license\nCopyright (C) 2014 Bruno Sutic\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE\nOR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Tmux Plugin Manager\n\n[![Build Status](https://travis-ci.org/tmux-plugins/tpm.svg?branch=master)](https://travis-ci.org/tmux-plugins/tpm)\n\nInstalls and loads `tmux` plugins.\n\nTested and working on Linux, OSX, and Cygwin.\n\nSee list of plugins [here](https://github.com/tmux-plugins/list).\n\n### Installation\n\nRequirements: `tmux` version 1.9 (or higher), `git`, `bash`.\n\nClone TPM:\n\n```bash\ngit clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm\n```\n\nPut this at the bottom of `~/.tmux.conf` (`$XDG_CONFIG_HOME/tmux/tmux.conf`\nworks too):\n\n```bash\n# List of plugins\nset -g @plugin 'tmux-plugins/tpm'\nset -g @plugin 'tmux-plugins/tmux-sensible'\n\n# Other examples:\n# set -g @plugin 'github_username/plugin_name'\n# set -g @plugin 'github_username/plugin_name#branch'\n# set -g @plugin 'git@github.com:user/plugin'\n# set -g @plugin 'git@bitbucket.com:user/plugin'\n\n# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)\nrun '~/.tmux/plugins/tpm/tpm'\n```\n\nReload TMUX environment so TPM is sourced:\n\n```bash\n# type this in terminal if tmux is already running\ntmux source ~/.tmux.conf\n```\n\nThat's it!\n\n### Installing plugins\n\n1. Add new plugin to `~/.tmux.conf` with `set -g @plugin '...'`\n2. Press `prefix` + <kbd>I</kbd> (capital i, as in **I**nstall) to fetch the plugin.\n\nYou're good to go! The plugin was cloned to `~/.tmux/plugins/` dir and sourced.\n\n### Uninstalling plugins\n\n1. Remove (or comment out) plugin from the list.\n2. Press `prefix` + <kbd>alt</kbd> + <kbd>u</kbd> (lowercase u as in **u**ninstall) to remove the plugin.\n\nAll the plugins are installed to `~/.tmux/plugins/` so alternatively you can\nfind plugin directory there and remove it.\n\n### Key bindings\n\n`prefix` + <kbd>I</kbd>\n- Installs new plugins from GitHub or any other git repository\n- Refreshes TMUX environment\n\n`prefix` + <kbd>U</kbd>\n- updates plugin(s)\n\n`prefix` + <kbd>alt</kbd> + <kbd>u</kbd>\n- remove/uninstall plugins not on the plugin list\n\n### Docs\n\n- [Help, tpm not working](docs/tpm_not_working.md) - problem solutions\n\nMore advanced features and instructions, regular users probably do not need\nthis:\n\n- [How to create a plugin](docs/how_to_create_plugin.md). It's easy.\n- [Managing plugins via the command line](docs/managing_plugins_via_cmd_line.md)\n- [Changing plugins install dir](docs/changing_plugins_install_dir.md)\n- [Automatic TPM installation on a new machine](docs/automatic_tpm_installation.md)\n\n### Tests\n\nTests for this project run on [Travis CI](https://travis-ci.org/tmux-plugins/tpm).\n\nWhen run locally, [vagrant](https://www.vagrantup.com/) is required.\nRun tests with:\n\n```bash\n# within project directory\n./run_tests\n```\n\n### License\n\n[MIT](LICENSE.md)\n"
  },
  {
    "path": "bin/clean_plugins",
    "content": "#!/usr/bin/env bash\n\n# Script intended for use via the command line.\n#\n# `.tmux.conf` needs to be set for TPM. Tmux has to be installed on the system,\n# but does not need to be started in order to run this script.\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nSCRIPTS_DIR=\"$CURRENT_DIR/../scripts\"\n\nmain() {\n\t\"$SCRIPTS_DIR/clean_plugins.sh\" # has correct exit code\n}\nmain\n"
  },
  {
    "path": "bin/install_plugins",
    "content": "#!/usr/bin/env bash\n\n# Script intended for use via the command line.\n#\n# `.tmux.conf` needs to be set for TPM. Tmux has to be installed on the system,\n# but does not need to be started in order to run this script.\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nSCRIPTS_DIR=\"$CURRENT_DIR/../scripts\"\n\nmain() {\n\t\"$SCRIPTS_DIR/install_plugins.sh\" # has correct exit code\n}\nmain\n"
  },
  {
    "path": "bin/update_plugins",
    "content": "#!/usr/bin/env bash\n\n# Script intended for use via the command line.\n#\n# `.tmux.conf` needs to be set for TPM. Tmux has to be installed on the system,\n# but does not need to be started in order to run this script.\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nSCRIPTS_DIR=\"$CURRENT_DIR/../scripts\"\nPROGRAM_NAME=\"$0\"\n\nif [ $# -eq 0 ]; then\n\techo \"usage:\"\n\techo \"  $PROGRAM_NAME all                   update all plugins\"\n\techo \"  $PROGRAM_NAME tmux-foo              update plugin 'tmux-foo'\"\n\techo \"  $PROGRAM_NAME tmux-bar tmux-baz     update multiple plugins\"\n\texit 1\nfi\n\nmain() {\n\t\"$SCRIPTS_DIR/update_plugin.sh\" --shell-echo \"$*\" # has correct exit code\n}\nmain \"$*\"\n\n"
  },
  {
    "path": "bindings/clean_plugins",
    "content": "#!/usr/bin/env bash\n\n# Tmux key-binding script.\n# Scripts intended to be used via the command line are in `bin/` directory.\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nSCRIPTS_DIR=\"$CURRENT_DIR/../scripts\"\nHELPERS_DIR=\"$SCRIPTS_DIR/helpers\"\n\nsource \"$HELPERS_DIR/tmux_echo_functions.sh\"\nsource \"$HELPERS_DIR/tmux_utils.sh\"\n\nmain() {\n\treload_tmux_environment\n\t\"$SCRIPTS_DIR/clean_plugins.sh\" --tmux-echo >/dev/null 2>&1\n\treload_tmux_environment\n\tend_message\n}\nmain\n"
  },
  {
    "path": "bindings/install_plugins",
    "content": "#!/usr/bin/env bash\n\n# Tmux key-binding script.\n# Scripts intended to be used via the command line are in `bin/` directory.\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nSCRIPTS_DIR=\"$CURRENT_DIR/../scripts\"\nHELPERS_DIR=\"$SCRIPTS_DIR/helpers\"\n\nsource \"$HELPERS_DIR/tmux_echo_functions.sh\"\nsource \"$HELPERS_DIR/tmux_utils.sh\"\n\nmain() {\n\treload_tmux_environment\n\t\"$SCRIPTS_DIR/install_plugins.sh\" --tmux-echo >/dev/null 2>&1\n\treload_tmux_environment\n\tend_message\n}\nmain\n"
  },
  {
    "path": "bindings/update_plugins",
    "content": "#!/usr/bin/env bash\n\n# Tmux key-binding script.\n# Scripts intended to be used via the command line are in `bin/` directory.\n\n# This script:\n# - shows a list of installed plugins\n# - starts a prompt to enter the name of the plugin that will be updated\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nSCRIPTS_DIR=\"$CURRENT_DIR/../scripts\"\nHELPERS_DIR=\"$SCRIPTS_DIR/helpers\"\n\nsource \"$HELPERS_DIR/plugin_functions.sh\"\nsource \"$HELPERS_DIR/tmux_echo_functions.sh\"\nsource \"$HELPERS_DIR/tmux_utils.sh\"\n\ndisplay_plugin_update_list() {\n\tlocal plugins=\"$(tpm_plugins_list_helper)\"\n\ttmux_echo \"Installed plugins:\"\n\ttmux_echo \"\"\n\n\tfor plugin in $plugins; do\n\t\t# displaying only installed plugins\n\t\tif plugin_already_installed \"$plugin\"; then\n\t\t\tlocal plugin_name=\"$(plugin_name_helper \"$plugin\")\"\n\t\t\ttmux_echo \"  $plugin_name\"\n\t\tfi\n\tdone\n\n\ttmux_echo \"\"\n\ttmux_echo \"Type plugin name to update it.\"\n\ttmux_echo \"\"\n\ttmux_echo \"- \\\"all\\\" - updates all plugins\"\n\ttmux_echo \"- ENTER - cancels\"\n}\n\nupdate_plugin_prompt() {\n\ttmux command-prompt -p 'plugin update:' \" \\\n\t\tsend-keys C-c; \\\n\t\trun-shell '$SCRIPTS_DIR/update_plugin_prompt_handler.sh %1'\"\n}\n\nmain() {\n\treload_tmux_environment\n\tdisplay_plugin_update_list\n\tupdate_plugin_prompt\n}\nmain\n"
  },
  {
    "path": "docs/automatic_tpm_installation.md",
    "content": "# Automatic tpm installation\n\nOne of the first things we do on a new machine is cloning our dotfiles. Not everything comes with them though, so for example `tpm` most likely won't be installed.\n\nIf you want to install `tpm` and plugins automatically when tmux is started, put the following snippet in `.tmux.conf` before the final `run '~/.tmux/plugins/tpm/tpm'`:\n\n```\nif \"test ! -d ~/.tmux/plugins/tpm\" \\\n   \"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'\"\n```\n\nThis useful tip was submitted by @acr4 and narfman0.\n"
  },
  {
    "path": "docs/changing_plugins_install_dir.md",
    "content": "# Changing plugins install dir\n\nBy default, TPM installs plugins in a subfolder named `plugins/` inside\n`$XDG_CONFIG_HOME/tmux/` if a `tmux.conf` file was found at that location, or\ninside `~/.tmux/` otherwise.\n\nYou can change the install path by putting this in `.tmux.conf`:\n\n    set-environment -g TMUX_PLUGIN_MANAGER_PATH '/some/other/path/'\n\nTmux plugin manager initialization in `.tmux.conf` should also be updated:\n\n    # initializes TMUX plugin manager in a new path\n    run /some/other/path/tpm/tpm\n\nPlease make sure that the `run` line is at the very bottom of `.tmux.conf`.\n"
  },
  {
    "path": "docs/how_to_create_plugin.md",
    "content": "# How to create Tmux plugins\n\nCreating a new plugin is easy.\n\nFor demonstration purposes we'll create a simple plugin that lists all\ninstalled TPM plugins. Yes, a plugin that lists plugins :) We'll bind that to\n`prefix + T`.\n\nThe source code for this example plugin can be found\n[here](https://github.com/tmux-plugins/tmux-example-plugin).\n\n### 1. create a new git project\n\nTPM depends on git for downloading and updating plugins.\n\nTo create a new git project:\n\n    $ mkdir tmux_my_plugin\n    $ cd tmux_my_plugin\n    $ git init\n\n### 2. create a `*.tmux` plugin run file\n\nWhen it sources a plugin, TPM executes all `*.tmux` files in your plugins'\ndirectory. That's how plugins are run.\n\nCreate a plugin run file in plugin directory:\n\n    $ touch my_plugin.tmux\n    $ chmod u+x my_plugin.tmux\n\nYou can have more than one `*.tmux` file, and all will get executed. However, usually\nyou'll need just one.\n\n### 3. create a plugin key binding\n\nWe want the behavior of the plugin to trigger when a user hits `prefix + T`.\n\nKey `T` is chosen because:\n - it's \"kind of\" a mnemonic for `TPM`\n - the key is not used by Tmux natively. Tmux man page, KEY BINDINGS section\n   contains a list of all the bindings Tmux uses. There's plenty of unused keys\n   and we don't want to override any of Tmux default key bindings.\n\nOpen the plugin run file in your favorite text editor:\n\n    $ vim my_plugin.tmux\n    # or\n    $ subl my_plugin.tmux\n\nPut the following content in the file:\n\n    #!/usr/bin/env bash\n\n    CURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n    tmux bind-key T run-shell \"$CURRENT_DIR/scripts/tmux_list_plugins.sh\"\n\nAs you can see, plugin run file is a simple bash script that sets up the binding.\n\nWhen pressed, `prefix + T` will execute another shell script:\n`tmux_list_plugins.sh`. That script should be in `scripts/` directory -\nrelative to the plugin run file.\n\n\n### 4. listing plugins\n\nNow that we have the binding, let's create a script that's invoked with\n`prefix + T`.\n\n    $ mkdir scripts\n    $ touch scripts/tmux_list_plugins.sh\n    $ chmod u+x scripts/tmux_list_plugins.sh\n\nAnd here's the script content:\n\n    #!/usr/bin/env bash\n\n    # fetching the directory where plugins are installed\n    plugin_path=\"$(tmux show-env -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)\"\n\n    # listing installed plugins\n    ls -1 \"$plugin_path\"\n\n### 5. try it out\n\nTo see if this works, execute the plugin run file:\n\n    $ ./my_plugin.tmux\n\nThat should set up the key binding. Now hit `prefix + T` and see if it works.\n\n### 6. publish the plugin\n\nWhen everything is ready, push the plugin to an online git repository,\npreferably GitHub.\n\nOther users can install your plugin by just adding plugin git URL to the\n`@plugin` list in their `.tmux.conf`.\n\nIf the plugin is on GitHub, your users will be able to use the shorthand of\n`github_username/repository`.\n\n### Conclusion\n\nHopefully, that was easy. As you can see, it's mostly shell scripting.\n\nYou can use other scripting languages (ruby, python etc) but plain old shell\nis preferred because of portability.\n"
  },
  {
    "path": "docs/managing_plugins_via_cmd_line.md",
    "content": "# Managing plugins via the command line\n\nAside from tmux key bindings, TPM provides shell interface for managing plugins\nvia scripts located in [bin/](../bin/) directory.\n\nTmux does not need to be started in order to run scripts (but it's okay if it\nis). If you [changed tpm install dir](../docs/changing_plugins_install_dir.md)\nin `.tmux.conf` that should work fine too.\n\nPrerequisites:\n\n- tmux installed on the system (doh)\n- `.tmux.conf` set up for TPM\n\n### Installing plugins\n\nAs usual, plugins need to be specified in `.tmux.conf`. Run the following\ncommand to install plugins:\n\n    ~/.tmux/plugins/tpm/bin/install_plugins\n\n### Updating plugins\n\nTo update all installed plugins:\n\n    ~/.tmux/plugins/tpm/bin/update_plugins all\n\nor update a single plugin:\n\n    ~/.tmux/plugins/tpm/bin/update_plugins tmux-sensible\n\n### Removing plugins\n\nTo remove plugins not on the plugin list:\n\n    ~/.tmux/plugins/tpm/bin/clean_plugins\n"
  },
  {
    "path": "docs/tpm_not_working.md",
    "content": "# Help, tpm not working!\n\nHere's the list of issues users had with `tpm`:\n\n<hr />\n\n> Nothing works. `tpm` key bindings `prefix + I`, `prefix + U` not even\n  defined.\n\nRelated [issue #22](https://github.com/tmux-plugins/tpm/issues/22)\n\n- Do you have required `tmux` version to run `tpm`?<br/>\n  Check `tmux` version with `$ tmux -V` command and make sure it's higher or\n  equal to the required version for `tpm` as stated in the readme.\n\n- ZSH tmux plugin might be causing issues.<br/>\n  If you have it installed, try disabling it and see if `tpm` works then.\n\n<hr />\n\n> Help, I'm using custom config file with `tmux -f /path/to/my_tmux.conf`\nto start Tmux and for some reason plugins aren't loaded!?\n\nRelated [issue #57](https://github.com/tmux-plugins/tpm/issues/57)\n\n`tpm` has a known issue when using custom config file with `-f` option.\nThe solution is to use alternative plugin definition syntax. Here are the steps\nto make it work:\n\n1. remove all `set -g @plugin` lines from tmux config file\n2. in the config file define the plugins in the following way:\n\n        # List of plugins\n        set -g @tpm_plugins '          \\\n          tmux-plugins/tpm             \\\n          tmux-plugins/tmux-sensible   \\\n          tmux-plugins/tmux-resurrect  \\\n        '\n\n        # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)\n        run '~/.tmux/plugins/tpm/tpm'\n\n3. Reload TMUX environment so TPM is sourced: `$ tmux source /path/to/my_tmux.conf`\n\nThe plugins should now be working.\n\n<hr />\n\n> Weird sequence of characters show up when installing or updating plugins\n\nRelated: [issue #25](https://github.com/tmux-plugins/tpm/issues/25)\n\n- This could be caused by [tmuxline.vim](https://github.com/edkolev/tmuxline.vim)\n  plugin. Uninstall it and see if things work.\n\n<hr />\n\n> \"failed to connect to server\" error when sourcing .tmux.conf\n\nRelated: [issue #48](https://github.com/tmux-plugins/tpm/issues/48)\n\n- Make sure `tmux source ~/.tmux.conf` command is ran from inside `tmux`.\n\n<hr />\n\n> tpm not working: '~/.tmux/plugins/tpm/tpm' returned 2 (Windows / Cygwin)\n\nRelated: [issue #81](https://github.com/tmux-plugins/tpm/issues/81)\n\nThis issue is most likely caused by Windows line endings. For example, if you\nhave git's `core.autocrlf` option set to `true`, git will automatically convert\nall the files to Windows line endings which might cause a problem.\n\nThe solution is to convert all line ending to Unix newline characters. This\ncommand handles that for all files under `.tmux/` dir (skips `.git`\nsubdirectories):\n\n```bash\nfind ~/.tmux -type d -name '.git*' -prune -o -type f -print0 | xargs -0 dos2unix\n```\n\n<hr />\n\n> '~/.tmux/plugins/tpm/tpm' returned 127 (on macOS, w/ tmux installed using brew)\n\nRelated: [issue #67](https://github.com/tmux-plugins/tpm/issues/67)\n\nThis problem is because tmux's `run-shell` command runs a shell which doesn't read from user configs, thus tmux installed in a brew prefix (e.g. `/usr/local/bin`) will not be found.\n\nThe solution is to find your brew prefix\n\n```sh\n> echo \"$(brew --prefix)/bin\"\n/opt/homebrew/bin\n```\n\nAnd prepend it to the `PATH` environment variable\n```\nset-environment -g PATH \"/opt/homebrew/bin:/bin:/usr/bin\"\n```\n\nbefore any `run-shell`/`run` commands in `~/.tmux.conf`.\n"
  },
  {
    "path": "scripts/check_tmux_version.sh",
    "content": "#!/usr/bin/env bash\n\nVERSION=\"$1\"\nUNSUPPORTED_MSG=\"$2\"\n\nget_tmux_option() {\n\tlocal option=$1\n\tlocal default_value=$2\n\tlocal option_value=$(tmux show-option -gqv \"$option\")\n\tif [ -z \"$option_value\" ]; then\n\t\techo \"$default_value\"\n\telse\n\t\techo \"$option_value\"\n\tfi\n}\n\n# Ensures a message is displayed for 5 seconds in tmux prompt.\n# Does not override the 'display-time' tmux option.\ndisplay_message() {\n\tlocal message=\"$1\"\n\n\t# display_duration defaults to 5 seconds, if not passed as an argument\n\tif [ \"$#\" -eq 2 ]; then\n\t\tlocal display_duration=\"$2\"\n\telse\n\t\tlocal display_duration=\"5000\"\n\tfi\n\n\t# saves user-set 'display-time' option\n\tlocal saved_display_time=$(get_tmux_option \"display-time\" \"750\")\n\n\t# sets message display time to 5 seconds\n\ttmux set-option -gq display-time \"$display_duration\"\n\n\t# displays message\n\ttmux display-message \"$message\"\n\n\t# restores original 'display-time' value\n\ttmux set-option -gq display-time \"$saved_display_time\"\n}\n\n# this is used to get \"clean\" integer version number. Examples:\n# `tmux 1.9` => `19`\n# `1.9a`     => `19`\nget_digits_from_string() {\n\tlocal string=\"$1\"\n\tlocal only_digits=\"$(echo \"$string\" | tr -dC '[:digit:]')\"\n\techo \"$only_digits\"\n}\n\ntmux_version_int() {\n\tlocal tmux_version_string=$(tmux -V)\n\techo \"$(get_digits_from_string \"$tmux_version_string\")\"\n}\n\nunsupported_version_message() {\n\tif [ -n \"$UNSUPPORTED_MSG\" ]; then\n\t\techo \"$UNSUPPORTED_MSG\"\n\telse\n\t\techo \"Error, Tmux version unsupported! Please install Tmux version $VERSION or greater!\"\n\tfi\n}\n\nexit_if_unsupported_version() {\n\tlocal current_version=\"$1\"\n\tlocal supported_version=\"$2\"\n\tif [ \"$current_version\" -lt \"$supported_version\" ]; then\n\t\tdisplay_message \"$(unsupported_version_message)\"\n\t\texit 1\n\tfi\n}\n\nmain() {\n\tlocal supported_version_int=\"$(get_digits_from_string \"$VERSION\")\"\n\tlocal current_version_int=\"$(tmux_version_int)\"\n\texit_if_unsupported_version \"$current_version_int\" \"$supported_version_int\"\n}\nmain\n"
  },
  {
    "path": "scripts/clean_plugins.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nHELPERS_DIR=\"$CURRENT_DIR/helpers\"\n\nsource \"$HELPERS_DIR/plugin_functions.sh\"\nsource \"$HELPERS_DIR/utility.sh\"\n\nif [ \"$1\" == \"--tmux-echo\" ]; then # tmux-specific echo functions\n\tsource \"$HELPERS_DIR/tmux_echo_functions.sh\"\nelse # shell output functions\n\tsource \"$HELPERS_DIR/shell_echo_functions.sh\"\nfi\n\nclean_plugins() {\n\tlocal plugins plugin plugin_directory\n\tplugins=\"$(tpm_plugins_list_helper)\"\n\n\tfor plugin_directory in \"$(tpm_path)\"/*; do\n\t\t[ -d \"${plugin_directory}\" ] || continue\n\t\tplugin=\"$(plugin_name_helper \"${plugin_directory}\")\"\n\t\tcase \"${plugins}\" in\n\t\t\t*\"${plugin}\"*) : ;;\n\t\t\t*)\n\t\t\t[ \"${plugin}\" = \"tpm\" ] && continue\n\t\t\techo_ok \"Removing \\\"$plugin\\\"\"\n\t\t\trm -rf \"${plugin_directory}\" >/dev/null 2>&1\n\t\t\t[ -d \"${plugin_directory}\" ] &&\n\t\t\techo_err \"  \\\"$plugin\\\" clean fail\" ||\n\t\t\techo_ok \"  \\\"$plugin\\\" clean success\"\n\t\t\t;;\n\t\tesac\n\tdone\n}\n\nmain() {\n\tensure_tpm_path_exists\n\tclean_plugins\n\texit_value_helper\n}\nmain\n"
  },
  {
    "path": "scripts/helpers/plugin_functions.sh",
    "content": "# using @tpm_plugins is now deprecated in favor of using @plugin syntax\ntpm_plugins_variable_name=\"@tpm_plugins\"\n\n# manually expanding tilde char or `$HOME` variable.\n_manual_expansion() {\n\tlocal path=\"$1\"\n\tlocal expanded_tilde=\"${path/#\\~/$HOME}\"\n\techo \"${expanded_tilde/#\\$HOME/$HOME}\"\n}\n\n_tpm_path() {\n\tlocal string_path=\"$(tmux start-server\\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/\"\n\t_manual_expansion \"$string_path\"\n}\n\n_CACHED_TPM_PATH=\"$(_tpm_path)\"\n\n# Get the absolute path to the users configuration file of TMux.\n# This includes a prioritized search on different locations.\n#\n_get_user_tmux_conf() {\n\t# Define the different possible locations.\n\txdg_location=\"${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf\"\n\tdefault_location=\"$HOME/.tmux.conf\"\n\n\t# Search for the correct configuration file by priority.\n\tif [ -f \"$xdg_location\" ]; then\n\t\techo \"$xdg_location\"\n\n\telse\n\t\techo \"$default_location\"\n\tfi\n}\n\n_tmux_conf_contents() {\n\tuser_config=$(_get_user_tmux_conf)\n\tcat /etc/tmux.conf \"$user_config\" 2>/dev/null\n\tif [ \"$1\" == \"full\" ]; then # also output content from sourced files\n\t\tlocal file\n\t\tfor file in $(_sourced_files); do\n\t\t\tcat $(_manual_expansion \"$file\") 2>/dev/null\n\t\tdone\n\tfi\n}\n\n# return files sourced from tmux config files\n_sourced_files() {\n\t_tmux_conf_contents |\n\t\tsed -E -n -e \"s/^[[:space:]]*source(-file)?[[:space:]]+(-q+[[:space:]]+)?['\\\"]?([^'\\\"]+)['\\\"]?/\\3/p\"\n}\n\n# Want to be able to abort in certain cases\ntrap \"exit 1\" TERM\nexport TOP_PID=$$\n\n_fatal_error_abort() {\n\techo >&2 \"Aborting.\"\n\tkill -s TERM $TOP_PID\n}\n\n# PUBLIC FUNCTIONS BELOW\n\ntpm_path() {\n\tif [ \"$_CACHED_TPM_PATH\" == \"/\" ]; then\n\t\techo >&2 \"FATAL: Tmux Plugin Manager not configured in tmux.conf\"\n\t\t_fatal_error_abort\n\tfi\n\techo \"$_CACHED_TPM_PATH\"\n}\n\ntpm_plugins_list_helper() {\n\t# lists plugins from @tpm_plugins option\n\techo \"$(tmux start-server\\; show-option -gqv \"$tpm_plugins_variable_name\")\"\n\n\t# read set -g @plugin \"tmux-plugins/tmux-example-plugin\" entries\n\t_tmux_conf_contents \"full\" |\n\t\tawk '/^[ \\t]*set(-option)? +-g +@plugin/ { gsub(/'\\''/,\"\"); gsub(/'\\\"'/,\"\"); print $4 }'\n}\n\n# Allowed plugin name formats:\n# 1. \"git://github.com/user/plugin_name.git\"\n# 2. \"user/plugin_name\"\nplugin_name_helper() {\n\tlocal plugin=\"$1\"\n\t# get only the part after the last slash, e.g. \"plugin_name.git\"\n\tlocal plugin_basename=\"$(basename \"$plugin\")\"\n\t# remove \".git\" extension (if it exists) to get only \"plugin_name\"\n\tlocal plugin_name=\"${plugin_basename%.git}\"\n\techo \"$plugin_name\"\n}\n\nplugin_path_helper() {\n\tlocal plugin=\"$1\"\n\tlocal plugin_name=\"$(plugin_name_helper \"$plugin\")\"\n\techo \"$(tpm_path)${plugin_name}/\"\n}\n\nplugin_already_installed() {\n\tlocal plugin=\"$1\"\n\tlocal plugin_path=\"$(plugin_path_helper \"$plugin\")\"\n\t[ -d \"$plugin_path\" ] &&\n\t\tcd \"$plugin_path\" &&\n\t\tgit remote >/dev/null 2>&1\n}\n"
  },
  {
    "path": "scripts/helpers/shell_echo_functions.sh",
    "content": "echo_ok() {\n\techo \"$*\"\n}\n\necho_err() {\n\tfail_helper \"$*\"\n}\n"
  },
  {
    "path": "scripts/helpers/tmux_echo_functions.sh",
    "content": "_has_emacs_mode_keys() {\n\t$(tmux show -gw mode-keys | grep -q emacs)\n}\n\ntmux_echo() {\n\tlocal message=\"$1\"\n\ttmux run-shell \"echo '$message'\"\n}\n\necho_ok() {\n\ttmux_echo \"$*\"\n}\n\necho_err() {\n\ttmux_echo \"$*\"\n}\n\nend_message() {\n\tif _has_emacs_mode_keys; then\n\t\tlocal continue_key=\"ESCAPE\"\n\telse\n\t\tlocal continue_key=\"ENTER\"\n\tfi\n\ttmux_echo \"\"\n\ttmux_echo \"TMUX environment reloaded.\"\n\ttmux_echo \"\"\n\ttmux_echo \"Done, press $continue_key to continue.\"\n}\n"
  },
  {
    "path": "scripts/helpers/tmux_utils.sh",
    "content": "HELPERS_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nsource \"$HELPERS_DIR/plugin_functions.sh\"\n\nreload_tmux_environment() {\n\ttmux source-file $(_get_user_tmux_conf) >/dev/null 2>&1\n}\n"
  },
  {
    "path": "scripts/helpers/utility.sh",
    "content": "ensure_tpm_path_exists() {\n\tmkdir -p \"$(tpm_path)\"\n}\n\nfail_helper() {\n\tlocal message=\"$1\"\n\techo \"$message\" >&2\n\tFAIL=\"true\"\n}\n\nexit_value_helper() {\n\tif [ \"$FAIL\" == \"true\" ]; then\n\t\texit 1\n\telse\n\t\texit 0\n\tfi\n}\n"
  },
  {
    "path": "scripts/install_plugins.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nHELPERS_DIR=\"$CURRENT_DIR/helpers\"\n\nsource \"$HELPERS_DIR/plugin_functions.sh\"\nsource \"$HELPERS_DIR/utility.sh\"\n\nif [ \"$1\" == \"--tmux-echo\" ]; then # tmux-specific echo functions\n\tsource \"$HELPERS_DIR/tmux_echo_functions.sh\"\nelse # shell output functions\n\tsource \"$HELPERS_DIR/shell_echo_functions.sh\"\nfi\n\nclone() {\n\tlocal plugin=\"$1\"\n\tlocal branch=\"$2\"\n\tif [ -n \"$branch\" ]; then\n\t\tcd \"$(tpm_path)\" &&\n\t\t\tGIT_TERMINAL_PROMPT=0 git clone -b \"$branch\" --single-branch --recursive \"$plugin\" >/dev/null 2>&1\n\telse\n\t\tcd \"$(tpm_path)\" &&\n\t\t\tGIT_TERMINAL_PROMPT=0 git clone --single-branch --recursive \"$plugin\" >/dev/null 2>&1\n\tfi\n}\n\n# tries cloning:\n# 1. plugin name directly - works if it's a valid git url\n# 2. expands the plugin name to point to a GitHub repo and tries cloning again\nclone_plugin() {\n\tlocal plugin=\"$1\"\n\tlocal branch=\"$2\"\n\tclone \"$plugin\" \"$branch\" ||\n\t\tclone \"https://git::@github.com/$plugin\" \"$branch\"\n}\n\n# clone plugin and produce output\ninstall_plugin() {\n\tlocal plugin=\"$1\"\n\tlocal branch=\"$2\"\n\tlocal plugin_name=\"$(plugin_name_helper \"$plugin\")\"\n\n\tif plugin_already_installed \"$plugin\"; then\n\t\techo_ok \"Already installed \\\"$plugin_name\\\"\"\n\telse\n\t\techo_ok \"Installing \\\"$plugin_name\\\"\"\n\t\tclone_plugin \"$plugin\" \"$branch\" &&\n\t\t\techo_ok \"  \\\"$plugin_name\\\" download success\" ||\n\t\t\techo_err \"  \\\"$plugin_name\\\" download fail\"\n\tfi\n}\n\ninstall_plugins() {\n\tlocal plugins=\"$(tpm_plugins_list_helper)\"\n\tfor plugin in $plugins; do\n\t\tIFS='#' read -ra plugin <<< \"$plugin\"\n\t\tinstall_plugin \"${plugin[0]}\" \"${plugin[1]}\"\n\tdone\n}\n\nverify_tpm_path_permissions() {\n\tlocal path=\"$(tpm_path)\"\n\t# check the write permission flag for all users to ensure\n\t# that we have proper access\n\t[ -w \"$path\" ] ||\n\t\techo_err \"$path is not writable!\"\n}\n\nmain() {\n\tensure_tpm_path_exists\n\tverify_tpm_path_permissions\n\tinstall_plugins\n\texit_value_helper\n}\nmain\n"
  },
  {
    "path": "scripts/source_plugins.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nHELPERS_DIR=\"$CURRENT_DIR/helpers\"\n\nsource \"$HELPERS_DIR/plugin_functions.sh\"\n\nplugin_dir_exists() {\n\t[ -d \"$1\" ]\n}\n\n# Runs all *.tmux files from the plugin directory.\n# Files are ran as executables.\n# No errors if the plugin dir does not exist.\nsilently_source_all_tmux_files() {\n\tlocal plugin_path=\"$1\"\n\tlocal plugin_tmux_files=\"$plugin_path*.tmux\"\n\tif plugin_dir_exists \"$plugin_path\"; then\n\t\tfor tmux_file in $plugin_tmux_files; do\n\t\t\t# if the glob didn't find any files this will be the\n\t\t\t# unexpanded glob which obviously doesn't exist\n\t\t\t[ -f \"$tmux_file\" ] || continue\n\t\t\t# runs *.tmux file as an executable\n\t\t\t$tmux_file >/dev/null 2>&1\n\t\tdone\n\tfi\n}\n\nsource_plugins() {\n\tlocal plugin plugin_path\n\tlocal plugins=\"$(tpm_plugins_list_helper)\"\n\tfor plugin in $plugins; do\n\t\tIFS='#' read -ra plugin <<< \"$plugin\"\n\t\tplugin_path=\"$(plugin_path_helper \"${plugin[0]}\")\"\n\t\tsilently_source_all_tmux_files \"$plugin_path\"\n\tdone\n}\n\nmain() {\n\tsource_plugins\n}\nmain\n"
  },
  {
    "path": "scripts/update_plugin.sh",
    "content": "#!/usr/bin/env bash\n\n# this script handles core logic of updating plugins\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nHELPERS_DIR=\"$CURRENT_DIR/helpers\"\n\nsource \"$HELPERS_DIR/plugin_functions.sh\"\nsource \"$HELPERS_DIR/utility.sh\"\n\nif [ \"$1\" == \"--tmux-echo\" ]; then # tmux-specific echo functions\n\tsource \"$HELPERS_DIR/tmux_echo_functions.sh\"\nelse # shell output functions\n\tsource \"$HELPERS_DIR/shell_echo_functions.sh\"\nfi\n\n# from now on ignore first script argument\nshift\n\npull_changes() {\n\tlocal plugin=\"$1\"\n\tlocal plugin_path=\"$(plugin_path_helper \"$plugin\")\"\n\tcd \"$plugin_path\" &&\n\t\tGIT_TERMINAL_PROMPT=0 git pull &&\n\t\tGIT_TERMINAL_PROMPT=0 git submodule update --init --recursive\n}\n\nupdate() {\n\tlocal plugin=\"$1\" output\n\toutput=$(pull_changes \"$plugin\" 2>&1)\n\tif (( $? == 0 )); then\n\t\techo_ok \"  \\\"$plugin\\\" update success\"\n\t\techo_ok \"$(echo \"$output\" | sed -e 's/^/    | /')\"\n\telse\n\t\techo_err \"  \\\"$plugin\\\" update fail\"\n\t\techo_err \"$(echo \"$output\" | sed -e 's/^/    | /')\"\n\tfi\n}\n\nupdate_all() {\n\techo_ok \"Updating all plugins!\"\n\techo_ok \"\"\n\tlocal plugins=\"$(tpm_plugins_list_helper)\"\n\tfor plugin in $plugins; do\n\t\tIFS='#' read -ra plugin <<< \"$plugin\"\n\t\tlocal plugin_name=\"$(plugin_name_helper \"${plugin[0]}\")\"\n\t\t# updating only installed plugins\n\t\tif plugin_already_installed \"$plugin_name\"; then\n\t\t\tupdate \"$plugin_name\" &\n\t\tfi\n\tdone\n\twait\n}\n\nupdate_plugins() {\n\tlocal plugins=\"$*\"\n\tfor plugin in $plugins; do\n\t\tIFS='#' read -ra plugin <<< \"$plugin\"\n\t\tlocal plugin_name=\"$(plugin_name_helper \"${plugin[0]}\")\"\n\t\tif plugin_already_installed \"$plugin_name\"; then\n\t\t\tupdate \"$plugin_name\" &\n\t\telse\n\t\t\techo_err \"$plugin_name not installed!\" &\n\t\tfi\n\tdone\n\twait\n}\n\nmain() {\n\tensure_tpm_path_exists\n\tif [ \"$1\" == \"all\" ]; then\n\t\tupdate_all\n\telse\n\t\tupdate_plugins \"$*\"\n\tfi\n\texit_value_helper\n}\nmain \"$*\"\n"
  },
  {
    "path": "scripts/update_plugin_prompt_handler.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nHELPERS_DIR=\"$CURRENT_DIR/helpers\"\n\nif [ $# -eq 0 ]; then\n\texit 0\nfi\n\nsource \"$HELPERS_DIR/tmux_echo_functions.sh\"\nsource \"$HELPERS_DIR/tmux_utils.sh\"\n\nmain() {\n\t\"$CURRENT_DIR/update_plugin.sh\" --tmux-echo \"$*\"\n\treload_tmux_environment\n\tend_message\n}\nmain \"$*\"\n"
  },
  {
    "path": "scripts/variables.sh",
    "content": "install_key_option=\"@tpm-install\"\ndefault_install_key=\"I\"\n\nupdate_key_option=\"@tpm-update\"\ndefault_update_key=\"U\"\n\nclean_key_option=\"@tpm-clean\"\ndefault_clean_key=\"M-u\"\n\nSUPPORTED_TMUX_VERSION=\"1.9\"\n\nDEFAULT_TPM_ENV_VAR_NAME=\"TMUX_PLUGIN_MANAGER_PATH\"\nDEFAULT_TPM_PATH=\"$HOME/.tmux/plugins/\"\n"
  },
  {
    "path": "tests/expect_failed_plugin_download",
    "content": "#!/usr/bin/env expect\n\n# disables script output\nlog_user 0\n\nspawn tmux\n\n# Waiting for tmux to attach. If this is not done, next command, `send` will\n# not work properly.\nsleep 1\n\n# this is tmux prefix + I\nsend \"\u0002I\"\n\n# cloning might take a while\nset timeout 20\n\nexpect_after {\n  timeout { exit 1 }\n}\n\nexpect {\n  \"Installing \\\"non-existing-plugin\\\"\"\n}\n\nexpect {\n  \"\\\"non-existing-plugin\\\" download fail\"\n}\n\nexpect {\n  \"Done, press ENTER to continue\" {\n    exit 0\n  }\n}\n\nexit 1\n"
  },
  {
    "path": "tests/expect_successful_clean_plugins",
    "content": "#!/usr/bin/env expect\n\n# disables script output\nlog_user 0\n\nspawn tmux\n\n# Waiting for tmux to attach. If this is not done, next command, `send` will\n# not work properly.\nsleep 1\n\n# this is tmux prefix + alt + u\nsend \"\u0002\u001bu\"\n\nset timeout 5\n\nexpect_after {\n  timeout { exit 1 }\n}\n\nexpect {\n  \"Removing \\\"tmux-example-plugin\\\"\"\n}\n\nexpect {\n  \"\\\"tmux-example-plugin\\\" clean success\"\n}\n\nexpect {\n  \"Done, press ENTER to continue.\" {\n    exit 0\n  }\n}\n\nexit 1\n"
  },
  {
    "path": "tests/expect_successful_multiple_plugins_download",
    "content": "#!/usr/bin/env expect\n\n# disables script output\nlog_user 0\n\nspawn tmux\n\n# Waiting for tmux to attach. If this is not done, next command, `send` will\n# not work properly.\nsleep 1\n\n# this is tmux prefix + I\nsend \"\u0002I\"\n\n# cloning might take a while\nset timeout 15\n\nexpect_after {\n  timeout { exit 1 }\n}\n\nexpect {\n  \"Installing \\\"tmux-example-plugin\\\"\"\n}\n\nexpect {\n  \"\\\"tmux-example-plugin\\\" download success\"\n}\n\nexpect {\n  \"Installing \\\"tmux-copycat\\\"\"\n}\n\nexpect {\n  \"\\\"tmux-copycat\\\" download success\"\n}\n\nexpect {\n  \"Done, press ENTER to continue.\" {\n    exit 0\n  }\n}\n\nexit 1\n"
  },
  {
    "path": "tests/expect_successful_plugin_download",
    "content": "#!/usr/bin/env expect\n\n# disables script output\nlog_user 0\n\nspawn tmux\n\n# Waiting for tmux to attach. If this is not done, next command, `send` will\n# not work properly.\nsleep 1\n\n# this is tmux prefix + I\nsend \"\u0002I\"\n\n# cloning might take a while\nset timeout 15\n\nexpect_after {\n  timeout { exit 1 }\n}\n\nexpect {\n  \"Installing \\\"tmux-example-plugin\\\"\"\n}\n\nexpect {\n  \"\\\"tmux-example-plugin\\\" download success\"\n}\n\nexpect {\n  \"Done, press ENTER to continue\" {\n    send \"\r\"\n  }\n}\n\nsleep 1\n# this is tmux prefix + I\nsend \"\u0002I\"\n\nexpect {\n  \"Already installed \\\"tmux-example-plugin\\\"\"\n}\n\nexpect {\n  \"Done, press ENTER to continue\" {\n    exit 0\n  }\n}\n\nexit 1\n"
  },
  {
    "path": "tests/expect_successful_update_of_a_single_plugin",
    "content": "#!/usr/bin/env expect\n\n# disables script output\nlog_user 0\n\nspawn tmux\n\n# Waiting for tmux to attach. If this is not done, next command, `send` will\n# not work properly.\nsleep 1\n\n# this is tmux prefix + U\nsend \"\u0002U\"\n\nset timeout 15\n\nexpect_after {\n  timeout { exit 1 }\n}\n\nexpect {\n  \"Installed plugins\"\n}\n\nexpect {\n  \"tmux-example-plugin\"\n}\n\nexpect {\n  \"\\\"all\\\" - updates all plugins\"\n}\n\nexpect {\n  \"ENTER - cancels\"\n}\n\n# wait for tmux to display prompt before sending characters\nsleep 1\nsend \"tmux-example-plugin\\r\"\n\nexpect {\n  \"Updating \\\"tmux-example-plugin\\\"\"\n}\n\nexpect {\n  \"\\\"tmux-example-plugin\\\" update success\"\n}\n\nexpect {\n  \"Done, press ENTER to continue.\" {\n    exit 0\n  }\n}\n\nexit 1\n"
  },
  {
    "path": "tests/expect_successful_update_of_all_plugins",
    "content": "#!/usr/bin/env expect\n\n# disables script output\nlog_user 0\n\nspawn tmux\n\n# Waiting for tmux to attach. If this is not done, next command, `send` will\n# not work properly.\nsleep 1\n\n# this is tmux prefix + U\nsend \"\u0002U\"\n\nset timeout 5\n\nexpect_after {\n  timeout { exit 1 }\n}\n\nexpect {\n  \"Installed plugins\"\n}\n\nexpect {\n  \"tmux-example-plugin\"\n}\n\nexpect {\n  \"\\\"all\\\" - updates all plugins\"\n}\n\nexpect {\n  \"ENTER - cancels\"\n}\n\n# wait for tmux to display prompt before sending characters\nsleep 1\nsend \"all\\r\"\n\nexpect {\n  \"Updating all plugins!\"\n}\n\nexpect {\n  \"Updating \\\"tmux-example-plugin\\\"\"\n}\n\nexpect {\n  \"\\\"tmux-example-plugin\\\" update success\"\n}\n\nexpect {\n  \"Done, press ENTER to continue.\" {\n    exit 0\n  }\n}\n\nexit 1\n"
  },
  {
    "path": "tests/helpers/tpm.sh",
    "content": "check_dir_exists_helper() {\n\t[ -d \"$1\" ]\n}\n\n# runs the scripts and asserts it has the correct output and exit code\nscript_run_helper() {\n\tlocal script=\"$1\"\n\tlocal expected_output=\"$2\"\n\tlocal expected_exit_code=\"${3:-0}\"\n\t$script 2>&1 |\n\t\tgrep \"$expected_output\" >/dev/null 2>&1 && # grep -q flag quits the script early\n\t\t[ \"${PIPESTATUS[0]}\" -eq \"$expected_exit_code\" ]\n}\n"
  },
  {
    "path": "tests/test_plugin_clean.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nTPM_DIR=\"$PWD\"\nPLUGINS_DIR=\"$HOME/.tmux/plugins\"\n\nsource \"$CURRENT_DIR/helpers/helpers.sh\"\nsource \"$CURRENT_DIR/helpers/tpm.sh\"\n\nmanually_install_the_plugin() {\n\trm -rf \"$PLUGINS_DIR\"\n\tmkdir -p \"$PLUGINS_DIR\"\n\tcd \"$PLUGINS_DIR\"\n\tgit clone --quiet https://github.com/tmux-plugins/tmux-example-plugin\n}\n\n# TMUX KEY-BINDING TESTS\n\ntest_plugin_uninstallation_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmanually_install_the_plugin\n\n\t\"$CURRENT_DIR/expect_successful_clean_plugins\" ||\n\t\tfail_helper \"[key-binding] clean fails\"\n\n\tteardown_helper\n}\n\n# SCRIPT TESTS\n\ntest_plugin_uninstallation_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmanually_install_the_plugin\n\n\tscript_run_helper \"$TPM_DIR/bin/clean_plugins\" '\"tmux-example-plugin\" clean success' ||\n\t\tfail_helper \"[script] plugin cleaning fails\"\n\n\tteardown_helper\n}\n\ntest_unsuccessful_plugin_uninstallation_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmanually_install_the_plugin\n\tchmod 000 \"$PLUGINS_DIR/tmux-example-plugin\" # disable directory deletion\n\n\tlocal expected_exit_code=1\n\tscript_run_helper \"$TPM_DIR/bin/clean_plugins\" '\"tmux-example-plugin\" clean fail' \"$expected_exit_code\" ||\n\t\tfail_helper \"[script] unsuccessful plugin cleaning doesn't fail\"\n\n\tchmod 755 \"$PLUGINS_DIR/tmux-example-plugin\" # enable directory deletion\n\n\tteardown_helper\n}\n\nrun_tests\n"
  },
  {
    "path": "tests/test_plugin_installation.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nPLUGINS_DIR=\"$HOME/.tmux/plugins\"\nTPM_DIR=\"$PWD\"\n\nCUSTOM_PLUGINS_DIR=\"$HOME/foo/plugins\"\nADDITIONAL_CONFIG_FILE_1=\"$HOME/.tmux/additional_config_file_1\"\nADDITIONAL_CONFIG_FILE_2=\"$HOME/.tmux/additional_config_file_2\"\n\nsource \"$CURRENT_DIR/helpers/helpers.sh\"\nsource \"$CURRENT_DIR/helpers/tpm.sh\"\n\n# TMUX KEY-BINDING TESTS\n\ntest_plugin_installation_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\t\"$CURRENT_DIR/expect_successful_plugin_download\" ||\n\t\tfail_helper \"[key-binding] plugin installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[key-binding] plugin download fails\"\n\n\tteardown_helper\n}\n\ntest_plugin_installation_via_tmux_key_binding_set_option() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset-option -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\t\"$CURRENT_DIR/expect_successful_plugin_download\" ||\n\t\tfail_helper \"[key-binding][set-option] plugin installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[key-binding][set-option] plugin download fails\"\n\n\tteardown_helper\n}\n\ntest_plugin_installation_custom_dir_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset-environment -g TMUX_PLUGIN_MANAGER_PATH '$CUSTOM_PLUGINS_DIR'\n\n\tset -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\t\"$CURRENT_DIR/expect_successful_plugin_download\" ||\n\t\tfail_helper \"[key-binding][custom dir] plugin installation fails\"\n\n\tcheck_dir_exists_helper \"$CUSTOM_PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[key-binding][custom dir] plugin download fails\"\n\n\tteardown_helper\n\trm -rf \"$CUSTOM_PLUGINS_DIR\"\n}\n\ntest_non_existing_plugin_installation_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"tmux-plugins/non-existing-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\t\"$CURRENT_DIR/expect_failed_plugin_download\" ||\n\t\tfail_helper \"[key-binding] non existing plugin installation doesn't fail\"\n\n\tteardown_helper\n}\n\ntest_multiple_plugins_installation_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\t\\ \\ set  -g    @plugin 'tmux-plugins/tmux-copycat'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\t\"$CURRENT_DIR/expect_successful_multiple_plugins_download\" ||\n\t\tfail_helper \"[key-binding] multiple plugins installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[key-binding] plugin download fails (tmux-example-plugin)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-copycat/\" ||\n\t\tfail_helper \"[key-binding] plugin download fails (tmux-copycat)\"\n\n\tteardown_helper\n}\n\ntest_plugins_installation_from_sourced_file_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tsource '$ADDITIONAL_CONFIG_FILE_1'\n\tset -g @plugin 'tmux-plugins/tmux-example-plugin'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmkdir ~/.tmux\n\techo \"set -g @plugin 'tmux-plugins/tmux-copycat'\" > \"$ADDITIONAL_CONFIG_FILE_1\"\n\n\t\"$CURRENT_DIR/expect_successful_multiple_plugins_download\" ||\n\t\tfail_helper \"[key-binding][sourced file] plugins installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[key-binding][sourced file] plugin download fails (tmux-example-plugin)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-copycat/\" ||\n\t\tfail_helper \"[key-binding][sourced file] plugin download fails (tmux-copycat)\"\n\n\tteardown_helper\n}\n\ntest_plugins_installation_from_multiple_sourced_files_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\t\\ \\ source    '$ADDITIONAL_CONFIG_FILE_1'\n\tsource-file '$ADDITIONAL_CONFIG_FILE_2'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmkdir ~/.tmux\n\techo \"set -g @plugin 'tmux-plugins/tmux-example-plugin'\" > \"$ADDITIONAL_CONFIG_FILE_1\"\n\techo \"  set -g @plugin 'tmux-plugins/tmux-copycat'\" > \"$ADDITIONAL_CONFIG_FILE_2\"\n\n\t\"$CURRENT_DIR/expect_successful_multiple_plugins_download\" ||\n\t\tfail_helper \"[key-binding][multiple sourced files] plugins installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[key-binding][multiple sourced files] plugin download fails (tmux-example-plugin)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-copycat/\" ||\n\t\tfail_helper \"[key-binding][multiple sourced files] plugin download fails (tmux-copycat)\"\n\n\tteardown_helper\n}\n\n# SCRIPT TESTS\n\ntest_plugin_installation_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" '\"tmux-example-plugin\" download success' ||\n\t\tfail_helper \"[script] plugin installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[script] plugin download fails\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" 'Already installed \"tmux-example-plugin\"' ||\n\t\tfail_helper \"[script] plugin already installed message fail\"\n\n\tteardown_helper\n}\n\ntest_plugin_installation_custom_dir_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset-environment -g TMUX_PLUGIN_MANAGER_PATH '$CUSTOM_PLUGINS_DIR'\n\n\tset -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" '\"tmux-example-plugin\" download success' ||\n\t\tfail_helper \"[script][custom dir] plugin installation fails\"\n\n\tcheck_dir_exists_helper \"$CUSTOM_PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[script][custom dir] plugin download fails\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" 'Already installed \"tmux-example-plugin\"' ||\n\t\tfail_helper \"[script][custom dir] plugin already installed message fail\"\n\n\tteardown_helper\n\trm -rf \"$CUSTOM_PLUGINS_DIR\"\n}\n\ntest_non_existing_plugin_installation_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"tmux-plugins/non-existing-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tlocal expected_exit_code=1\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" '\"non-existing-plugin\" download fail' \"$expected_exit_code\" ||\n\t\tfail_helper \"[script] non existing plugin installation doesn't fail\"\n\n\tteardown_helper\n}\n\ntest_multiple_plugins_installation_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\t\\ \\ set  -g    @plugin 'tmux-plugins/tmux-copycat'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" '\"tmux-example-plugin\" download success' ||\n\t\tfail_helper \"[script] multiple plugins installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[script] plugin download fails (tmux-example-plugin)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-copycat/\" ||\n\t\tfail_helper \"[script] plugin download fails (tmux-copycat)\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" 'Already installed \"tmux-copycat\"' ||\n\t\tfail_helper \"[script] multiple plugins already installed message fail\"\n\n\tteardown_helper\n}\n\ntest_plugins_installation_from_sourced_file_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tsource '$ADDITIONAL_CONFIG_FILE_1'\n\tset -g @plugin 'tmux-plugins/tmux-example-plugin'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmkdir ~/.tmux\n\techo \"set -g @plugin 'tmux-plugins/tmux-copycat'\" > \"$ADDITIONAL_CONFIG_FILE_1\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" '\"tmux-copycat\" download success' ||\n\t\tfail_helper \"[script][sourced file] plugins installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[script][sourced file] plugin download fails (tmux-example-plugin)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-copycat/\" ||\n\t\tfail_helper \"[script][sourced file] plugin download fails (tmux-copycat)\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" 'Already installed \"tmux-copycat\"' ||\n\t\tfail_helper \"[script][sourced file] plugins already installed message fail\"\n\n\tteardown_helper\n}\n\ntest_plugins_installation_from_multiple_sourced_files_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\t\\ \\ source    '$ADDITIONAL_CONFIG_FILE_1'\n\tsource-file '$ADDITIONAL_CONFIG_FILE_2'\n\tset -g @plugin 'tmux-plugins/tmux-example-plugin'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmkdir ~/.tmux\n\techo \" set   -g @plugin 'tmux-plugins/tmux-copycat'\" > \"$ADDITIONAL_CONFIG_FILE_1\"\n\techo \"set -g @plugin 'tmux-plugins/tmux-sensible'\" > \"$ADDITIONAL_CONFIG_FILE_2\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" '\"tmux-sensible\" download success' ||\n\t\tfail_helper \"[script][multiple sourced files] plugins installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[script][multiple sourced files] plugin download fails (tmux-example-plugin)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-copycat/\" ||\n\t\tfail_helper \"[script][multiple sourced files] plugin download fails (tmux-copycat)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-sensible/\" ||\n\t\tfail_helper \"[script][multiple sourced files] plugin download fails (tmux-sensible)\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" 'Already installed \"tmux-sensible\"' ||\n\t\tfail_helper \"[script][multiple sourced files] plugins already installed message fail\"\n\n\tteardown_helper\n}\n\nrun_tests\n"
  },
  {
    "path": "tests/test_plugin_installation_legacy.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nPLUGINS_DIR=\"$HOME/.tmux/plugins\"\nTPM_DIR=\"$PWD\"\n\nsource \"$CURRENT_DIR/helpers/helpers.sh\"\nsource \"$CURRENT_DIR/helpers/tpm.sh\"\n\n# TMUX KEY-BINDING TESTS\n\ntest_plugin_installation_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @tpm_plugins \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\t# opens tmux and test it with `expect`\n\t$CURRENT_DIR/expect_successful_plugin_download ||\n\t\tfail_helper \"[key-binding] plugin installation fails\"\n\n\t# check plugin dir exists after download\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[key-binding] plugin download fails\"\n\n\tteardown_helper\n}\n\ntest_legacy_and_new_syntax_for_plugin_installation_work_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @tpm_plugins \"                   \\\n\t\ttmux-plugins/tmux-example-plugin    \\\n\t\"\n\tset -g @plugin 'tmux-plugins/tmux-copycat'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\t# opens tmux and test it with `expect`\n\t\"$CURRENT_DIR\"/expect_successful_multiple_plugins_download ||\n\t\tfail_helper \"[key-binding] multiple plugins installation fails\"\n\n\t# check plugin dir exists after download\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[key-binding] plugin download fails (tmux-example-plugin)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-copycat/\" ||\n\t\tfail_helper \"[key-binding] plugin download fails (tmux-copycat)\"\n\n\tteardown_helper\n}\n\n# SCRIPT TESTS\n\ntest_plugin_installation_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @tpm_plugins \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" '\"tmux-example-plugin\" download success' ||\n\t\tfail_helper \"[script] plugin installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[script] plugin download fails\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" 'Already installed \"tmux-example-plugin\"' ||\n\t\tfail_helper \"[script] plugin already installed message fail\"\n\n\tteardown_helper\n}\n\ntest_legacy_and_new_syntax_for_plugin_installation_work_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @tpm_plugins \"                   \\\n\t\ttmux-plugins/tmux-example-plugin    \\\n\t\"\n\tset -g @plugin 'tmux-plugins/tmux-copycat'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" '\"tmux-example-plugin\" download success' ||\n\t\tfail_helper \"[script] multiple plugin installation fails\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-example-plugin/\" ||\n\t\tfail_helper \"[script] plugin download fails (tmux-example-plugin)\"\n\n\tcheck_dir_exists_helper \"$PLUGINS_DIR/tmux-copycat/\" ||\n\t\tfail_helper \"[script] plugin download fails (tmux-copycat)\"\n\n\tscript_run_helper \"$TPM_DIR/bin/install_plugins\" 'Already installed \"tmux-copycat\"' ||\n\t\tfail_helper \"[script] multiple plugins already installed message fail\"\n\n\tteardown_helper\n}\n\nrun_tests\n"
  },
  {
    "path": "tests/test_plugin_sourcing.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nTPM_DIR=\"$PWD\"\nPLUGINS_DIR=\"$HOME/.tmux/plugins\"\n\nCUSTOM_PLUGINS_DIR=\"$HOME/foo/plugins\"\n\nsource \"$CURRENT_DIR/helpers/helpers.sh\"\nsource \"$CURRENT_DIR/helpers/tpm.sh\"\n\ncheck_binding_defined() {\n\tlocal binding=\"$1\"\n\ttmux list-keys | grep -q \"$binding\"\n}\n\ncreate_test_plugin_helper() {\n\tlocal plugin_path=\"$PLUGINS_DIR/tmux_test_plugin/\"\n\trm -rf \"$plugin_path\"\n\tmkdir -p \"$plugin_path\"\n\n\twhile read line; do\n\t\techo \"$line\" >> \"$plugin_path/test_plugin.tmux\"\n\tdone\n\tchmod +x \"$plugin_path/test_plugin.tmux\"\n}\n\ncheck_tpm_path() {\n\tlocal correct_tpm_path=\"$1\"\n\tlocal tpm_path=\"$(tmux start-server\\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)\"\n\t[ \"$correct_tpm_path\" == \"$tpm_path\" ]\n}\n\ntest_plugin_sourcing() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"doesnt_matter/tmux_test_plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\t# manually creates a local tmux plugin\n\tcreate_test_plugin_helper <<- HERE\n\ttmux bind-key R run-shell foo_command\n\tHERE\n\n\ttmux new-session -d  # tmux starts detached\n\tcheck_binding_defined \"R run-shell foo_command\" ||\n\t\tfail_helper \"Plugin sourcing fails\"\n\n\tteardown_helper\n}\n\ntest_default_tpm_path() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tcheck_tpm_path \"${PLUGINS_DIR}/\" ||\n\t\tfail_helper \"Default TPM path not correct\"\n\n\tteardown_helper\n}\n\ntest_custom_tpm_path() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset-environment -g TMUX_PLUGIN_MANAGER_PATH '$CUSTOM_PLUGINS_DIR'\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tcheck_tpm_path \"$CUSTOM_PLUGINS_DIR\" ||\n\t\tfail_helper \"Custom TPM path not correct\"\n\n\tteardown_helper\n}\n\nrun_tests\n"
  },
  {
    "path": "tests/test_plugin_update.sh",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nTPM_DIR=\"$PWD\"\nPLUGINS_DIR=\"$HOME/.tmux/plugins\"\n\nsource \"$CURRENT_DIR/helpers/helpers.sh\"\nsource \"$CURRENT_DIR/helpers/tpm.sh\"\n\nmanually_install_the_plugin() {\n\tmkdir -p \"$PLUGINS_DIR\"\n\tcd \"$PLUGINS_DIR\"\n\tgit clone --quiet https://github.com/tmux-plugins/tmux-example-plugin\n}\n\n# TMUX KEY-BINDING TESTS\n\ntest_plugin_update_via_tmux_key_binding() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmanually_install_the_plugin\n\n\t\"$CURRENT_DIR/expect_successful_update_of_all_plugins\" ||\n\t\tfail_helper \"[key-binding] 'update all plugins' fails\"\n\n\t\"$CURRENT_DIR/expect_successful_update_of_a_single_plugin\" ||\n\t\tfail_helper \"[key-binding] 'update single plugin' fails\"\n\n\tteardown_helper\n}\n\n# SCRIPT TESTS\n\ntest_plugin_update_via_script() {\n\tset_tmux_conf_helper <<- HERE\n\tset -g mode-keys vi\n\tset -g @plugin \"tmux-plugins/tmux-example-plugin\"\n\trun-shell \"$TPM_DIR/tpm\"\n\tHERE\n\n\tmanually_install_the_plugin\n\n\tlocal expected_exit_code=1\n\tscript_run_helper \"$TPM_DIR/bin/update_plugins\" 'usage' \"$expected_exit_code\" ||\n\t\tfail_helper \"[script] running update plugins without args should fail\"\n\n\tscript_run_helper \"$TPM_DIR/bin/update_plugins tmux-example-plugin\" '\"tmux-example-plugin\" update success' ||\n\t\tfail_helper \"[script] plugin update fails\"\n\n\tscript_run_helper \"$TPM_DIR/bin/update_plugins all\" '\"tmux-example-plugin\" update success' ||\n\t\tfail_helper \"[script] update all plugins fails\"\n\n\tteardown_helper\n}\n\nrun_tests\n"
  },
  {
    "path": "tpm",
    "content": "#!/usr/bin/env bash\n\nCURRENT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\nBINDINGS_DIR=\"$CURRENT_DIR/bindings\"\nSCRIPTS_DIR=\"$CURRENT_DIR/scripts\"\n\nsource \"$SCRIPTS_DIR/variables.sh\"\n\nget_tmux_option() {\n\tlocal option=\"$1\"\n\tlocal default_value=\"$2\"\n\tlocal option_value=\"$(tmux show-option -gqv \"$option\")\"\n\tif [ -z \"$option_value\" ]; then\n\t\techo \"$default_value\"\n\telse\n\t\techo \"$option_value\"\n\tfi\n}\n\ntpm_path_set() {\n\ttmux show-environment -g \"$DEFAULT_TPM_ENV_VAR_NAME\" >/dev/null 2>&1\n}\n\n# Check if configuration file exists at an XDG-compatible location, if so use\n# that directory for TMUX_PLUGIN_MANAGER_PATH. Otherwise use $DEFAULT_TPM_PATH.\nset_default_tpm_path() {\n\tlocal xdg_tmux_path=\"${XDG_CONFIG_HOME:-$HOME/.config}/tmux\"\n\tlocal tpm_path=\"$DEFAULT_TPM_PATH\"\n\n\tif [ -f \"$xdg_tmux_path/tmux.conf\" ]; then\n\t\ttpm_path=\"$xdg_tmux_path/plugins/\"\n\tfi\n\n\ttmux set-environment -g \"$DEFAULT_TPM_ENV_VAR_NAME\" \"$tpm_path\"\n}\n\n# Ensures TMUX_PLUGIN_MANAGER_PATH global env variable is set.\n#\n# Put this in `.tmux.conf` to override the default:\n# `set-environment -g TMUX_PLUGIN_MANAGER_PATH \"/some/other/path/\"`\nset_tpm_path() {\n\tif ! tpm_path_set; then\n\t\tset_default_tpm_path\n\tfi\n}\n\n# 1. Fetches plugin names from `@plugin` variables\n# 2. Creates full plugin path\n# 3. Sources all *.tmux files from each of the plugin directories\n#\t - no errors raised if directory does not exist\n# Files are sourced as tmux config files, not as shell scripts!\nsource_plugins() {\n\t\"$SCRIPTS_DIR/source_plugins.sh\" >/dev/null 2>&1\n}\n\n# prefix + I - downloads TPM plugins and reloads TMUX environment\n# prefix + U - updates a plugin (or all of them) and reloads TMUX environment\n# prefix + alt + u - remove unused TPM plugins and reloads TMUX environment\nset_tpm_key_bindings() {\n\tlocal install_key=\"$(get_tmux_option \"$install_key_option\" \"$default_install_key\")\"\n\ttmux bind-key \"$install_key\" run-shell \"$BINDINGS_DIR/install_plugins\"\n\n\tlocal update_key=\"$(get_tmux_option \"$update_key_option\" \"$default_update_key\")\"\n\ttmux bind-key \"$update_key\" run-shell \"$BINDINGS_DIR/update_plugins\"\n\n\tlocal clean_key=\"$(get_tmux_option \"$clean_key_option\" \"$default_clean_key\")\"\n\ttmux bind-key \"$clean_key\" run-shell \"$BINDINGS_DIR/clean_plugins\"\n}\n\nsupported_tmux_version_ok() {\n\t\"$SCRIPTS_DIR/check_tmux_version.sh\" \"$SUPPORTED_TMUX_VERSION\"\n}\n\nmain() {\n\tif supported_tmux_version_ok; then\n\t\tset_tpm_path\n\t\tset_tpm_key_bindings\n\t\tsource_plugins\n\tfi\n}\nmain\n"
  }
]