Set $window var based on currently active window

Previously $window was only set by the new_window() helper when it was
passed a name argument. This caused weird behavior cause if it was
called without a name it would simply attempt to recreate the same
window and fail. That was until @blueyed's fix in 2249cf8.

However, the $window var still wasn't being set correctly, leaving
split_v(), split_h() and other helpers to operate on the wrong
window. This is no longer an issue as $window is always set to the index
of the currently active window at the end of new_window() and
select_window().
This commit is contained in:
2014-08-29 22:29:03 +01:00
parent 0ae0bc84e3
commit ef0f25591c
3 changed files with 72 additions and 7 deletions

View File

@@ -18,13 +18,11 @@ tmux() {
# - $2: (optional) Shell command to execute when window is created.
#
new_window() {
if [ -n "$1" ]; then
window="$1"
local winarg=(-n "$window")
fi
if [ -n "$1" ]; then local winarg=(-n "$1"); fi
if [ -n "$2" ]; then local command=("$2"); fi
tmuxifier-tmux new-window -t "$session:" "${winarg[@]}" "${command[@]}"
window="$(__get_current_window_index)"
__go_to_window_or_session_path
}
@@ -91,6 +89,7 @@ clock() {
#
select_window() {
tmuxifier-tmux select-window -t "$session:$1"
window="$(__get_current_window_index)"
}
# Select a specific pane in the current window.