mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 01:46:40 +00:00
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()"
|
||||
|
||||
Reference in New Issue
Block a user