diff --git a/README.md b/README.md index 8ae17cb..d560605 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ run '~/.tmux/plugins/tpm/tpm' Reload TMUX environment so TPM is sourced: ```bash -# type this in terminal +# type this in terminal if tmux is already running $ tmux source ~/.tmux.conf ``` diff --git a/docs/automatic_tpm_installation.md b/docs/automatic_tpm_installation.md index 22ded34..630573f 100644 --- a/docs/automatic_tpm_installation.md +++ b/docs/automatic_tpm_installation.md @@ -2,11 +2,11 @@ One 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. -If you wanna install `tpm` automatically when tmux is started, put the following snippet in `.tmux.conf` before the final `run '~/.tmux/plugins/tpm/tpm'`: +If 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'`: ``` if "test ! -d ~/.tmux/plugins/tpm" \ - "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm'" + "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'" ``` -This useful tip was submitted by @acr4. +This useful tip was submitted by @acr4 and narfman0. diff --git a/docs/tpm_not_working.md b/docs/tpm_not_working.md index 459ab01..87d2998 100644 --- a/docs/tpm_not_working.md +++ b/docs/tpm_not_working.md @@ -2,10 +2,12 @@ Here's the list of issues users had with `tpm`: +
+ > Nothing works. `tpm` key bindings `prefix + I`, `prefix + U` not even defined. -[Issue #22](https://github.com/tmux-plugins/tpm/issues/22) +Related [issue #22](https://github.com/tmux-plugins/tpm/issues/22) - Do you have required `tmux` version to run `tpm`?
Check `tmux` version with `$ tmux -V` command and make sure it's higher or @@ -14,10 +16,12 @@ Here's the list of issues users had with `tpm`: - ZSH tmux plugin might be causing issues.
If you have it installed, try disabling it and see if `tpm` works then. +
+ > Help, I'm using custom config file with `tmux -f /path/to/my_tmux.conf` to start Tmux and for some reason plugins aren't loaded!? -[Issue #57](https://github.com/tmux-plugins/tpm/issues/57) +Related [issue #57](https://github.com/tmux-plugins/tpm/issues/57) `tpm` has a known issue when using custom config file with `-f` option. The solution is to use alternative plugin definition syntax. Here are the steps @@ -40,15 +44,37 @@ to make it work: The plugins should now be working. +
+ > Weird sequence of characters show up when installing or updating plugins -[Issue #25](https://github.com/tmux-plugins/tpm/issues/25) +Related: [issue #25](https://github.com/tmux-plugins/tpm/issues/25) - This could be caused by [tmuxline.vim](https://github.com/edkolev/tmuxline.vim) plugin. Uninstall it and see if things work. +
+ > "failed to connect to server" error when sourcing .tmux.conf -[Issue #48](https://github.com/tmux-plugins/tpm/issues/48) +Related: [issue #48](https://github.com/tmux-plugins/tpm/issues/48) - Make sure `tmux source ~/.tmux.conf` command is ran from inside `tmux`. + +
+ +> tpm not working: '~/.tmux/plugins/tpm/tpm' returned 2 (Windows / Cygwin) + +Related: [issue #81](https://github.com/tmux-plugins/tpm/issues/81) + +This issue is most likely caused by Windows line endings. For example, if you +have git's `core.autocrlf` option set to `true`, git will automatically convert +all the files to Windows line endings which might cause a problem. + +The solution is to convert all line ending to Unix newline characters. This +command handles that for all files under `.tmux/` dir (skips `.git` +subdirectories): + +```bash +find ~/.tmux -type d -name '.git*' -prune -o -type f -print0 | xargs -0 dos2unix +``` diff --git a/scripts/helpers/plugin_functions.sh b/scripts/helpers/plugin_functions.sh index 6ee7a5d..d2778d5 100644 --- a/scripts/helpers/plugin_functions.sh +++ b/scripts/helpers/plugin_functions.sh @@ -28,12 +28,25 @@ _tmux_conf_contents() { # return files sourced from tmux config files _sourced_files() { _tmux_conf_contents | - awk '/^ *source(-file)? +/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $2 }' + awk '/^[ \t]*source(-file)? +/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $2 }' +} + +# Want to be able to abort in certain cases +trap "exit 1" TERM +export TOP_PID=$$ + +_fatal_error_abort() { + echo >&2 "Aborting." + kill -s TERM $TOP_PID } # PUBLIC FUNCTIONS BELOW tpm_path() { + if [ "$_CACHED_TPM_PATH" == "/" ]; then + echo >&2 "FATAL: Tmux Plugin Manager not configured in tmux.conf" + _fatal_error_abort + fi echo "$_CACHED_TPM_PATH" } @@ -43,7 +56,7 @@ tpm_plugins_list_helper() { # read set -g @plugin "tmux-plugins/tmux-example-plugin" entries _tmux_conf_contents "full" | - awk '/^ *set(-option)? +-g +@plugin/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $4 }' + awk '/^[ \t]*set(-option)? +-g +@plugin/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $4 }' } # Allowed plugin name formats: diff --git a/scripts/update_plugin.sh b/scripts/update_plugin.sh index d923d83..7d856ee 100755 --- a/scripts/update_plugin.sh +++ b/scripts/update_plugin.sh @@ -27,7 +27,6 @@ pull_changes() { update() { local plugin="$1" - echo_ok "Updating \"$plugin\"" $(pull_changes "$plugin" > /dev/null 2>&1) && echo_ok " \"$plugin\" update success" || echo_err " \"$plugin\" update fail" @@ -41,9 +40,10 @@ update_all() { local plugin_name="$(plugin_name_helper "$plugin")" # updating only installed plugins if plugin_already_installed "$plugin_name"; then - update "$plugin_name" + update "$plugin_name" & fi done + wait } update_plugins() { @@ -51,14 +51,16 @@ update_plugins() { for plugin in $plugins; do local plugin_name="$(plugin_name_helper "$plugin")" if plugin_already_installed "$plugin_name"; then - update "$plugin_name" + update "$plugin_name" & else - echo_err "$plugin_name not installed!" + echo_err "$plugin_name not installed!" & fi done + wait } main() { + ensure_tpm_path_exists if [ "$1" == "all" ]; then update_all else