Simpler additional tmux splits
This commit is contained in:
@@ -13,10 +13,8 @@ bind -T copy-mode-vi v send -X begin-selection
|
|||||||
bind -T copy-mode-vi y send -X copy-selection-and-cancel
|
bind -T copy-mode-vi y send -X copy-selection-and-cancel
|
||||||
|
|
||||||
# Pane Controls
|
# Pane Controls
|
||||||
bind -n M-Enter run-shell \
|
bind -n M-Enter split-window -v -c "#{pane_current_path}"
|
||||||
"[[ $(tmux list-panes | wc -l) -eq 1 ]] && \
|
bind -n M-S-Enter split-window -h -c "#{pane_current_path}"
|
||||||
tmux splitw -h -c '#{pane_current_path}' || \
|
|
||||||
tmux splitw -v -c '#{pane_current_path}'"
|
|
||||||
bind h split-window -v -c "#{pane_current_path}"
|
bind h split-window -v -c "#{pane_current_path}"
|
||||||
bind v split-window -h -c "#{pane_current_path}"
|
bind v split-window -h -c "#{pane_current_path}"
|
||||||
bind x kill-pane
|
bind x kill-pane
|
||||||
|
|||||||
+14
-21
@@ -1,28 +1,21 @@
|
|||||||
echo "Add Alt+Enter smart split keybinding to tmux"
|
echo "Add Alt+Enter and Alt+Shift+Enter split keybindings to tmux"
|
||||||
|
|
||||||
tmux_config="$HOME/.config/tmux/tmux.conf"
|
tmux_config="$HOME/.config/tmux/tmux.conf"
|
||||||
|
|
||||||
if [[ -f $tmux_config ]] && ! grep -q "bind -n M-Enter run-shell" "$tmux_config"; then
|
if [[ -f $tmux_config ]]; then
|
||||||
if grep -q '^bind ? display-popup .*omarchy-menu-tmux-keybindings' "$tmux_config"; then
|
changed=0
|
||||||
sed -i '/^bind ? display-popup .*omarchy-menu-tmux-keybindings/a bind -n M-Enter run-shell \\
|
|
||||||
"[[ $(tmux list-panes | wc -l) -eq 1 ]] \&\& \\
|
|
||||||
tmux splitw -h -c '\''#{pane_current_path}'\'' || \\
|
|
||||||
tmux splitw -v -c '\''#{pane_current_path}'\''"' "$tmux_config"
|
|
||||||
elif grep -q '^bind q source-file .*Configuration reloaded' "$tmux_config"; then
|
|
||||||
sed -i '/^bind q source-file .*Configuration reloaded/a bind -n M-Enter run-shell \\
|
|
||||||
"[[ $(tmux list-panes | wc -l) -eq 1 ]] \&\& \\
|
|
||||||
tmux splitw -h -c '\''#{pane_current_path}'\'' || \\
|
|
||||||
tmux splitw -v -c '\''#{pane_current_path}'\''"' "$tmux_config"
|
|
||||||
else
|
|
||||||
cat >>"$tmux_config" <<'EOF'
|
|
||||||
|
|
||||||
# Smart split: horizontal from one pane, vertical otherwise
|
if ! grep -qxF 'bind -n M-Enter split-window -v -c "#{pane_current_path}"' "$tmux_config"; then
|
||||||
bind -n M-Enter run-shell \
|
printf '\nbind -n M-Enter split-window -v -c "#{pane_current_path}"\n' >>"$tmux_config"
|
||||||
"[[ $(tmux list-panes | wc -l) -eq 1 ]] && \
|
changed=1
|
||||||
tmux splitw -h -c '#{pane_current_path}' || \
|
|
||||||
tmux splitw -v -c '#{pane_current_path}'"
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
omarchy-restart-tmux
|
if ! grep -qxF 'bind -n M-S-Enter split-window -h -c "#{pane_current_path}"' "$tmux_config"; then
|
||||||
|
printf 'bind -n M-S-Enter split-window -h -c "#{pane_current_path}"\n' >>"$tmux_config"
|
||||||
|
changed=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( changed )); then
|
||||||
|
omarchy-restart-tmux
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user