Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sourced file names in tmux format #244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/helpers/plugin_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tpm_plugins_variable_name="@tpm_plugins"
_manual_expansion() {
local path="$1"
local expanded_tilde="${path/#\~/$HOME}"
echo "${expanded_tilde/#\$HOME/$HOME}"
tmux display-message -p "${expanded_tilde/#\$HOME/$HOME}"
}

_tpm_path() {
Expand Down Expand Up @@ -46,7 +46,7 @@ _tmux_conf_contents() {
# return files sourced from tmux config files
_sourced_files() {
_tmux_conf_contents |
sed -E -n -e "s/^[[:space:]]*source(-file)?[[:space:]]+(-q+[[:space:]]+)?['\"]?([^'\"]+)['\"]?/\3/p"
sed -E -n -e "s/^[[:space:]]*source(-file)?[[:space:]]+(-[qF]+[[:space:]]+)?['\"]?([^'\"]+)['\"]?/\3/p"
}

# Want to be able to abort in certain cases
Expand Down
27 changes: 27 additions & 0 deletions tests/test_plugin_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,33 @@ test_plugins_installation_from_sourced_file_via_script() {
teardown_helper
}

test_plugins_installation_from_sourced_file_name_in_tmux_format_via_script() {
set_tmux_conf_helper <<- HERE
set -g mode-keys vi
set -g ADDITIONAL_CONFIG_FILE "$ADDITIONAL_CONFIG_FILE_1"
source -F '#{ADDITIONAL_CONFIG_FILE}'
set -g @plugin 'tmux-plugins/tmux-example-plugin'
run-shell "$TPM_DIR/tpm"
HERE

mkdir ~/.tmux
echo "set -g @plugin 'tmux-plugins/tmux-copycat'" > "$ADDITIONAL_CONFIG_FILE_1"

script_run_helper "$TPM_DIR/bin/install_plugins" '"tmux-copycat" download success' ||
fail_helper "[script][sourced file] plugins installation fails"

check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
fail_helper "[script][sourced file] plugin download fails (tmux-example-plugin)"

check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
fail_helper "[script][sourced file] plugin download fails (tmux-copycat)"

script_run_helper "$TPM_DIR/bin/install_plugins" 'Already installed "tmux-copycat"' ||
fail_helper "[script][sourced file] plugins already installed message fail"

teardown_helper
}

test_plugins_installation_from_multiple_sourced_files_via_script() {
set_tmux_conf_helper <<- HERE
set -g mode-keys vi
Expand Down