tmux: Better window dragging through swap-window
This commit is contained in:
@@ -80,24 +80,8 @@ bind -r C-p prev
|
||||
bind -r N swap-window -d -t :+1
|
||||
bind -r P swap-window -d -t :-1
|
||||
|
||||
# Reorder windows by dragging on status line.
|
||||
# NOTE: This breaks the stack and last-used window.
|
||||
bind -n MouseDragEnd1Status {
|
||||
# TODO: Can we somehow get the idx of {mouse} without selecting it?
|
||||
set -F @source_idx "#{window_index}"
|
||||
select-window -t=
|
||||
set -F @target_idx "#{window_index}"
|
||||
if -F "#{!=:#{@source_idx},#{window_index}}" { select-window -t! }
|
||||
|
||||
# Depending on the direction the window must be placed before or after
|
||||
# the target
|
||||
tmux_move_direction="#{?#{e|<:#{@target_idx},#{@source_idx}},-b,-a}"
|
||||
|
||||
# NOTE: uses run-shell so the flag can be passed through a variable
|
||||
run-shell "tmux move-window -t #{@target_idx} $tmux_move_direction"
|
||||
|
||||
setenv -u tmux_move_direction
|
||||
}
|
||||
# Reorder windows by dragging them in the status line.
|
||||
bind -n MouseDrag1Status swap-window -d -t=
|
||||
|
||||
# TODO: do nothing on drags that don't start on a window name
|
||||
bind -n MouseDragEnd1StatusDefault \
|
||||
|
||||
Reference in New Issue
Block a user