From 595269dd6a15e720d48ec294ddabec24a5dbaae5 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 25 Jul 2015 13:24:02 +0100 Subject: [PATCH 1/2] Make load-window within a session adhere to session_root setting This should fix #61. Previously when you manually ran `tmuxifier load-window` from within a session created by Tmuxifier, the `session_root` path set in the session was ignored, and the new window would be cd'd to `$HOME` unless the window configuration had `window_root` set. --- lib/layout-helpers.sh | 21 ++++++++-- .../__go_to_window_or_session_path.test.sh | 39 +++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/lib/layout-helpers.sh b/lib/layout-helpers.sh index 7daec41..e8f012c 100644 --- a/lib/layout-helpers.sh +++ b/lib/layout-helpers.sh @@ -261,6 +261,11 @@ initialize_session() { -d -s "$session" "${session_args[@]}" fi + if $set_default_path && [[ "$session_root" != "$HOME" ]]; then + tmuxifier-tmux setenv -t "$session:" \ + TMUXIFIER_SESSION_ROOT "$session_root" + fi + # In order to ensure only specified windows are created, we move the # default window to position 999, and later remove it with the # `finalize_and_go_to_session` function. @@ -331,9 +336,19 @@ __go_to_session() { } __go_to_window_or_session_path() { - local window_or_session_root=${window_root-$session_root} - if [ -n "$window_or_session_root" ]; then - run_cmd "cd \"$window_or_session_root\"" + local target_path + + if [ -n "$window_root" ]; then + target_path="$window_root" + elif [ -n "$TMUXIFIER_SESSION_ROOT" ]; then + target_path="$TMUXIFIER_SESSION_ROOT" + elif [ -n "$session_root" ]; then + target_path="$session_root" + fi + + # local window_or_session_root=${window_root-$session_root} + if [ -n "$target_path" ]; then + run_cmd "cd \"$target_path\"" run_cmd "clear" fi } diff --git a/test/lib/layout-helpers/__go_to_window_or_session_path.test.sh b/test/lib/layout-helpers/__go_to_window_or_session_path.test.sh index 4d6542f..bdb5e2c 100755 --- a/test/lib/layout-helpers/__go_to_window_or_session_path.test.sh +++ b/test/lib/layout-helpers/__go_to_window_or_session_path.test.sh @@ -23,6 +23,17 @@ unset window_root restore run_cmd +# When only $TMUXIFIER_SESSION_ROOT is set, runs cd to $TMUXIFIER_SESSION_ROOT +# path. +stub run_cmd +TMUXIFIER_SESSION_ROOT="/opt" +__go_to_window_or_session_path +assert 'stub_called_with_times run_cmd cd \"/opt\"' "1" +assert 'stub_called_with_times run_cmd clear' "1" +unset TMUXIFIER_SESSION_ROOT +restore run_cmd + + # When only $session_root is set, runs cd to $session_root path. stub run_cmd session_root="/usr" @@ -45,5 +56,33 @@ unset session_root restore run_cmd +# When $TMUXIFIER_SESSION_ROOT and $session_root are set, runs cd to +# $TMUXIFIER_SESSION_ROOT path. +stub run_cmd +TMUXIFIER_SESSION_ROOT="/opt" +session_root="/usr" +__go_to_window_or_session_path +assert 'stub_called_with_times run_cmd cd \"/opt\"' "1" +assert 'stub_called_with_times run_cmd clear' "1" +unset TMUXIFIER_SESSION_ROOT +unset session_root +restore run_cmd + + +# When $window_root, $TMUXIFIER_SESSION_ROOT, and $session_root are set, runs +# cd to $window_root path. +stub run_cmd +window_root="/tmp" +TMUXIFIER_SESSION_ROOT="/opt" +session_root="/usr" +__go_to_window_or_session_path +assert 'stub_called_with_times run_cmd cd \"/tmp\"' "1" +assert 'stub_called_with_times run_cmd clear' "1" +unset window_root +unset TMUXIFIER_SESSION_ROOT +unset session_root +restore run_cmd + + # End of tests. assert_end "__go_to_window_or_session_path()" From dafa938923370e4fd1497cde7c5c214d385ba524 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 25 Jul 2015 13:27:12 +0100 Subject: [PATCH 2/2] Add Tmux 2.0 to Travis-CI test environments --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0cd9f49..85eb9ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ env: - TMUX_VERSION="1.7" - TMUX_VERSION="1.8" - TMUX_VERSION="1.9a" + - TMUX_VERSION="2.0" before_install: - sudo apt-get update - sudo apt-get install -y bc build-essential libevent-dev libncurses5-dev