Skip to content

Commit

Permalink
tmux: replace ranger with yazi, change split window options
Browse files Browse the repository at this point in the history
  • Loading branch information
c02y committed Sep 17, 2024
1 parent fe45310 commit a1e1557
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions tmux/.config/tmux/tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ set -s default-terminal "screen-256color"
# set -s terminal-overrides "*256col*:colors=256,xterm*:XT,xterm-termite:Tc"
# setw -g xterm-keys on

# https://github.com/sxyazi/yazi/wiki/Image-preview-within-tmux
set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM

# use mouse to scroll the output page instead of the command history
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# fix the konsole/yakuake bug github#933
Expand Down Expand Up @@ -75,11 +80,11 @@ bind ? list-keys -a
unbind d
# NOTE: display-menu is introduced in v3.2
bind M-a display-menu -T "#[align=centre]Menu(j/k)" -xC -yC \
Ranger r "display-popup -E -w 90% -h 90% ranger" \
Yazi r "display-popup -E -w 90% -h 90% yazi" \
Btop b "display-popup -E -w 90% -h 90% btop" \
Top t "display-popup -E -w 90% -h 90% top" \
Man m "display-popup -E -w 90% -h 90% mman" \
Ranger-new-window R "new-window -n ranger ranger" \
Yazi-new-window R "new-window -n yazi yazi" \
Btop-new-window B "new-window -n btop btop" \
Top-new-window T "new-window -n top top" \
Man-new-window M "new-window -n man mman" \
Expand Down Expand Up @@ -122,19 +127,19 @@ bind -r Tab next-window
# "drag the popup around by the border or M-Button1 on the content, resize with M-Button3."
# doesn't work if keys are conflicted with wm keys
# the toggle part is copied from https://www.reddit.com/r/tmux/comments/olgte7/comment/id4hr9n/?utm_source=share&utm_medium=web2x&context=3
bind f if -F "#{window_zoomed_flag}" "resize-pane -Z; last-pane" "if -F '#{==:#{session_name},scratch}' {detach-client} {display-popup -E -x 115% -y 50% -w 45% -h 80% 'tmux new-session -A -s scratch -c \"#{pane_current_path}\"'}"
bind '\' if -F "#{window_zoomed_flag}" "resize-pane -Z; last-pane" "display-popup -E -x 115% -y 50% -w 45% -h 80% 'tmux new-session -A -s scratch -c \"#{pane_current_path}\"'"
bind '\' if -F "#{window_zoomed_flag}" "resize-pane -Z; last-pane" "if -F '#{==:#{session_name},scratch}' {detach-client} {display-popup -E -x 115% -y 50% -w 45% -h 80% 'tmux new-session -A -s scratch -c \"#{pane_current_path}\"'}"
# bind '\' if -F "#{window_zoomed_flag}" "resize-pane -Z; last-pane" "display-popup -E -x 115% -y 50% -w 45% -h 80% 'tmux new-session -A -s scratch -c \"#{pane_current_path}\"'"
# smart split window bindings: if in zoomed mode, unzoom, otherwise, split the window
# Vertial split-window from current dir
bind v if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -p 50 -h -c "#{pane_current_path}"'
bind M-'\' if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -p 50 -h -c "#{pane_current_path}"'
bind v if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -h -c "#{pane_current_path}"'
bind M-'\' if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -h -c "#{pane_current_path}"'
# split pane smart way, 8/20 numbers just make it more equal visually then just pane_width/pane_height
bind Enter if -F '#{e|>=|:#{e|*|:8,#{pane_width}},#{e|*|:20,#{pane_height}}}' \
"if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -p 50 -h -c \"#{pane_current_path}\"'" \
"if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -p 50 -c \"#{pane_current_path}\"'"
"if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -h -c \"#{pane_current_path}\"'" \
"if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -c \"#{pane_current_path}\"'"
# Horizontal split-window from current dir
bind h if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -p 50 -c "#{pane_current_path}"'
bind - if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -p 50 -c "#{pane_current_path}"'
bind h if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -c "#{pane_current_path}"'
bind - if -F '#{window_zoomed_flag}' 'resize-pane -Z; last-pane' 'split-window -c "#{pane_current_path}"'
bind c new-window
# create new window from the current dir
bind M-w new-window -c "#{pane_current_path}"
Expand Down Expand Up @@ -221,7 +226,7 @@ set -g pane-active-border-style fg='#2e9ef4'
# set-option -g pane-border-format "#{?pane_active,#[reverse],}#{pane_index}#[default] ""\"#(tmux display-message -p \"#{=50:pane_title}\" | sed \"s#$HOME#~#g\")\""
# default of pane-border-format
# set-option -g pane-border-format "#{?pane_active,#[reverse],}#{pane_index}#[default] ""\"#{pane_title}\""
set -g pane-border-format "#{?window_zoomed_flag,#[fg=red bold],}#[reverse]#(echo '#')#{pane_index}: #{s|$HOME|~|:pane_current_path} #(~/.local/bin/gitmux -timeout 2s #{pane_current_path})#[default]"
set -g pane-border-format "#{?window_zoomed_flag,#[fg=red bold],}#[reverse]#(echo '#')#{pane_index}: #{s|$HOME|~|:pane_current_path} #(gitmux -timeout 2s #{pane_current_path})#[default]"
# use prefix+z to max/restore the current pane
bind z "resize-pane -Z"
Expand Down

0 comments on commit a1e1557

Please sign in to comment.