mirror of
				https://github.com/tmux-plugins/tpm.git
				synced 2025-11-04 08:36:05 +00:00 
			
		
		
		
	New and old plugin syntax work together
This commit is contained in:
		@@ -8,6 +8,8 @@
 | 
				
			|||||||
- revert back to using `-g` flag in new plugin definition syntax
 | 
					- revert back to using `-g` flag in new plugin definition syntax
 | 
				
			||||||
- permit leading whitespace with new plugin definition syntax (thanks @chilicuil)
 | 
					- permit leading whitespace with new plugin definition syntax (thanks @chilicuil)
 | 
				
			||||||
- make sure `TMUX_PLUGIN_MANAGER_PATH` always has trailng slash
 | 
					- make sure `TMUX_PLUGIN_MANAGER_PATH` always has trailng slash
 | 
				
			||||||
 | 
					- ensure old/deprecated plugin syntax `set -g @tpm_plugins` works alongside new
 | 
				
			||||||
 | 
					  `set -g @plugin` syntax
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### v1.2.2, 2015-02-08
 | 
					### v1.2.2, 2015-02-08
 | 
				
			||||||
- set GIT_TERMINAL_PROMPT=0 when doing `git clone`, `pull` or `submodule update`
 | 
					- set GIT_TERMINAL_PROMPT=0 when doing `git clone`, `pull` or `submodule update`
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
# shared functions and constants
 | 
					# shared functions and constants
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# using @tpm_plugins is now deprecated in favor of using @plugin syntax
 | 
				
			||||||
tpm_plugins_variable_name="@tpm_plugins"
 | 
					tpm_plugins_variable_name="@tpm_plugins"
 | 
				
			||||||
SHARED_TPM_PATH=""
 | 
					SHARED_TPM_PATH=""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -11,16 +12,17 @@ shared_set_tpm_path_constant() {
 | 
				
			|||||||
	SHARED_TPM_PATH="$(echo "$string_path" | sed "s,^\$HOME,$HOME," | sed "s,^~,$HOME,")"
 | 
						SHARED_TPM_PATH="$(echo "$string_path" | sed "s,^\$HOME,$HOME," | sed "s,^~,$HOME,")"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					_tmux_conf_contents() {
 | 
				
			||||||
 | 
						cat /etc/tmux.conf ~/.tmux.conf 2>/dev/null
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
shared_get_tpm_plugins_list() {
 | 
					shared_get_tpm_plugins_list() {
 | 
				
			||||||
	local plugins_list
 | 
						# DEPRECATED: lists plugins from @tpm_plugins option
 | 
				
			||||||
	plugins_list="$(tmux show-option -gqv "$tpm_plugins_variable_name")"
 | 
						echo "$(tmux show-option -gqv "$tpm_plugins_variable_name")"
 | 
				
			||||||
	if [ -z "${plugins_list}" ]; then
 | 
					
 | 
				
			||||||
		#read set -g @plugin "tmux-plugins/tmux-example-plugin" entries
 | 
						# read set -g @plugin "tmux-plugins/tmux-example-plugin" entries
 | 
				
			||||||
		cat /etc/tmux.conf ~/.tmux.conf 2>/dev/null |
 | 
						_tmux_conf_contents |
 | 
				
			||||||
			awk '/^ *set +-g +@plugin/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $4 }'
 | 
							awk '/^ *set +-g +@plugin/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $4 }'
 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		printf "%s\\n" "${plugins_list}"
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Allowed plugin name formats:
 | 
					# Allowed plugin name formats:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,8 +21,32 @@ test_plugin_installation() {
 | 
				
			|||||||
	teardown_helper
 | 
						teardown_helper
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test_legacy_and_new_syntax_for_plugin_installation_work() {
 | 
				
			||||||
 | 
						set_tmux_conf_helper <<- HERE
 | 
				
			||||||
 | 
						set -g @tpm_plugins "                   \
 | 
				
			||||||
 | 
							tmux-plugins/tmux-example-plugin    \
 | 
				
			||||||
 | 
						"
 | 
				
			||||||
 | 
						set -g @plugin 'tmux-plugins/tmux-copycat'
 | 
				
			||||||
 | 
						run-shell "$PWD/tpm"
 | 
				
			||||||
 | 
						HERE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						# opens tmux and test it with `expect`
 | 
				
			||||||
 | 
						"$CURRENT_DIR"/expect_successful_multiple_plugins_download ||
 | 
				
			||||||
 | 
							fail_helper "Tmux multiple plugins installation fails"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						# check plugin dir exists after download
 | 
				
			||||||
 | 
						check_dir_exists_helper "$HOME/.tmux/plugins/tmux-example-plugin/" ||
 | 
				
			||||||
 | 
							fail_helper "Plugin download fails (tmux-example-plugin)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						check_dir_exists_helper "$HOME/.tmux/plugins/tmux-copycat/" ||
 | 
				
			||||||
 | 
							fail_helper "Plugin download fails (tmux-copycat)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						teardown_helper
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
main() {
 | 
					main() {
 | 
				
			||||||
	test_plugin_installation
 | 
						test_plugin_installation
 | 
				
			||||||
 | 
						test_legacy_and_new_syntax_for_plugin_installation_work
 | 
				
			||||||
	exit_value_helper
 | 
						exit_value_helper
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
main
 | 
					main
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user