mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 01:46:40 +00:00
Fix issue #7
Instead of assuming that the default created window in a new session has a index of `0`, we now check window index for the session with Tmux's list-windows command. Additionally, the default window is now moved to index `999` instead of `99`, cause I'm paranoid and probably stupid :)
This commit is contained in:
@@ -182,9 +182,10 @@ initialize_session() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# In order to ensure only specified windows are created, we move the
|
# In order to ensure only specified windows are created, we move the
|
||||||
# default window to position 99, and later remove it with the
|
# default window to position 999, and later remove it with the
|
||||||
# `finalize_session` function.
|
# `finalize_and_go_to_session` function.
|
||||||
tmux move-window -s "$session:0" -t "$session:99"
|
local first_window_index=$(__get_first_window_index)
|
||||||
|
tmux move-window -s "$session:$first_window_index" -t "$session:999"
|
||||||
|
|
||||||
# Ensure correct pane splitting.
|
# Ensure correct pane splitting.
|
||||||
__go_to_session
|
__go_to_session
|
||||||
@@ -207,7 +208,7 @@ initialize_session() {
|
|||||||
# to it here.
|
# to it here.
|
||||||
#
|
#
|
||||||
finalize_and_go_to_session() {
|
finalize_and_go_to_session() {
|
||||||
! tmux kill-window -t "$session:99" 2>/dev/null
|
! tmux kill-window -t "$session:999" 2>/dev/null
|
||||||
if [[ "$(tmuxifier-current-session)" != "$session" ]]; then
|
if [[ "$(tmuxifier-current-session)" != "$session" ]]; then
|
||||||
__go_to_session
|
__go_to_session
|
||||||
fi
|
fi
|
||||||
@@ -229,6 +230,16 @@ __expand_path() {
|
|||||||
echo $(eval echo "$@")
|
echo $(eval echo "$@")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__get_first_window_index() {
|
||||||
|
local index
|
||||||
|
index=$(tmux list-windows -t "$session:" -F "#{window_index}" 2>/dev/null)
|
||||||
|
if [ -n "$index" ]; then
|
||||||
|
echo "$index" | head -1
|
||||||
|
else
|
||||||
|
echo "0"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
__go_to_session() {
|
__go_to_session() {
|
||||||
if [ -z "$TMUX" ]; then
|
if [ -z "$TMUX" ]; then
|
||||||
tmux -u attach-session -t "$session:"
|
tmux -u attach-session -t "$session:"
|
||||||
|
|||||||
Reference in New Issue
Block a user