mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
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
|
||||
|
||||
# Pane Controls
|
||||
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}'"
|
||||
bind -n M-Enter split-window -v -c "#{pane_current_path}"
|
||||
bind -n M-S-Enter split-window -h -c "#{pane_current_path}"
|
||||
bind h split-window -v -c "#{pane_current_path}"
|
||||
bind v split-window -h -c "#{pane_current_path}"
|
||||
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"
|
||||
|
||||
if [[ -f $tmux_config ]] && ! grep -q "bind -n M-Enter run-shell" "$tmux_config"; then
|
||||
if grep -q '^bind ? display-popup .*omarchy-menu-tmux-keybindings' "$tmux_config"; then
|
||||
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'
|
||||
if [[ -f $tmux_config ]]; then
|
||||
changed=0
|
||||
|
||||
# Smart split: horizontal from one pane, vertical otherwise
|
||||
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}'"
|
||||
EOF
|
||||
if ! grep -qxF 'bind -n M-Enter split-window -v -c "#{pane_current_path}"' "$tmux_config"; then
|
||||
printf '\nbind -n M-Enter split-window -v -c "#{pane_current_path}"\n' >>"$tmux_config"
|
||||
changed=1
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user