Move files out of their respective fs structure into program dirs in root and symlink dotfils using HM.
This commit is contained in:
parent
10bab010b7
commit
fb2adb4547
72 changed files with 9 additions and 0 deletions
131
tmux/.tmux.conf
Normal file
131
tmux/.tmux.conf
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
# For some reason, fzf is missing from path when running shell scripts through tmux keybindings
|
||||
set-environment -g PATH "~/dev/git/fzf/bin:$PATH"
|
||||
|
||||
# Keybindings for navigating between panes
|
||||
bind-key -n M-Left select-pane -L
|
||||
bind-key -n M-Down select-pane -D
|
||||
bind-key -n M-Up select-pane -U
|
||||
bind-key -n M-Right select-pane -R
|
||||
|
||||
# Resize mode
|
||||
set -g @tmux_resize_mode 0
|
||||
set -g @resize_mode_path "~/.config/tmux/tmux-set-resize-mode.sh"
|
||||
bind-key -n M-Space if-shell -F "#{==:#{@tmux_resize_mode},0}" "run-shell '#{@resize_mode_path} 1'" ""
|
||||
bind-key -n Escape if-shell -F "#{==:#{@tmux_resize_mode},1}" "run-shell '#{@resize_mode_path} 0'" "send-keys Escape"
|
||||
bind-key -n Enter if-shell -F "#{==:#{@tmux_resize_mode},1}" "run-shell '#{@resize_mode_path} 0'" "send-keys Enter"
|
||||
bind-key -n q if-shell -F "#{==:#{@tmux_resize_mode},1}" "run-shell '#{@resize_mode_path} 0'" "send-keys q"
|
||||
|
||||
# Resize the panes if we are in resize mode
|
||||
bind-key -n Up if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -U" "send-keys Up"
|
||||
bind-key -n Down if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -D" "send-keys Down"
|
||||
bind-key -n Left if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -L" "send-keys Left"
|
||||
bind-key -n Right if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -R" "send-keys Right"
|
||||
|
||||
bind-key -n M-p display-message "#{@tmux_resize_mode}"
|
||||
|
||||
bind-key -n M-d run-shell "~/.config/tmux/tmux-fuzzy-find-session.sh"
|
||||
|
||||
# Split window, change keybindings to match vim concept of splits
|
||||
bind-key -n M-v split-window -h
|
||||
bind-key -n M-h split-window -v
|
||||
bind-key -n M-q kill-pane
|
||||
bind-key -n M-f resize-pane -Z
|
||||
bind-key -n M-s command-prompt -p "New session: " "run-shell '~/.config/tmux/tmux-create-session.sh '%%''"
|
||||
bind-key -n M-w new-window
|
||||
bind-key -n M-r command-prompt -p "Rename window:" "rename-window '%%'"
|
||||
bind-key -n M-R command-prompt -p "Rename session:" "rename-session '%%'"
|
||||
|
||||
bind-key -n M-c copy-mode
|
||||
bind-key -T copy-mode-vi v send-keys -X begin-selection
|
||||
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
|
||||
bind-key -n M-0 select-window -t 0
|
||||
bind-key -n M-1 select-window -t 1
|
||||
bind-key -n M-2 select-window -t 2
|
||||
bind-key -n M-3 select-window -t 3
|
||||
bind-key -n M-4 select-window -t 4
|
||||
bind-key -n M-5 select-window -t 5
|
||||
bind-key -n M-6 select-window -t 6
|
||||
bind-key -n M-7 select-window -t 7
|
||||
bind-key -n M-8 select-window -t 8
|
||||
bind-key -n M-9 select-window -t 9
|
||||
|
||||
set -g @move-pane-path "~/.config/tmux/tmux-move-pane.sh"
|
||||
bind-key -n M-) run-shell "#{@move-pane-path} 0"
|
||||
bind-key -n M-! run-shell "#{@move-pane-path} 1"
|
||||
bind-key -n M-@ run-shell "#{@move-pane-path} 2"
|
||||
bind-key -n M-# run-shell "#{@move-pane-path} 3"
|
||||
bind-key -n M-$ run-shell "#{@move-pane-path} 4"
|
||||
bind-key -n M-% run-shell "#{@move-pane-path} 5"
|
||||
bind-key -n M-^ run-shell "#{@move-pane-path} 6"
|
||||
bind-key -n M-& run-shell "#{@move-pane-path} 7"
|
||||
bind-key -n M-* run-shell "#{@move-pane-path} 8"
|
||||
bind-key -n M-( run-shell "#{@move-pane-path} 9"
|
||||
|
||||
# Reload tmux configuration
|
||||
bind-key -n M-C source-file ~/.tmux.conf \; display-message "Config reloaded"
|
||||
|
||||
# Set the default terminal to support 256 colors
|
||||
set -g default-terminal "tmux-256color"
|
||||
|
||||
# Enable true color support in tmux
|
||||
set-option -ga terminal-features ',xterm-ghostty:RGB'
|
||||
set-option -ga terminal-features ',xterm-256color:RGB'
|
||||
set-option -ga terminal-features ',tmux-256color:RGB'
|
||||
|
||||
# Ensure tmux recognizes terminal overrides for true color
|
||||
set-option -ga terminal-overrides ',xterm-ghostty:Tc'
|
||||
set-option -ga terminal-overrides ',xterm-256color:Tc'
|
||||
set-option -ga terminal-overrides ',*:Tc'
|
||||
|
||||
# Specific overrides for underline and underline colors (requires tmux >= 3.0)
|
||||
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
|
||||
set -as terminal-overrides ',*:Setulc=\E[58::2::::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
|
||||
|
||||
# Make sure that the index of windows and panes starts at 1
|
||||
set -g base-index 1
|
||||
set -g pane-base-index 1
|
||||
set -g renumber-windows on
|
||||
|
||||
set -g mode-keys vi
|
||||
|
||||
set-option -g status-position top
|
||||
|
||||
# Address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
set -s escape-time 0
|
||||
|
||||
# Increase scrollback buffer size from 2000 to 50000 lines
|
||||
set -g history-limit 50000
|
||||
|
||||
# Increase tmux messages display duration from 750ms to 4s
|
||||
set -g display-time 2500
|
||||
|
||||
# Refresh 'status-left' and 'status-right' more often, from every 15s to 5s
|
||||
set -g status-interval 2
|
||||
|
||||
# Focus events enabled for terminals that support them
|
||||
set -g focus-events on
|
||||
|
||||
# Super useful when using "grouped sessions" and multi-monitor setup
|
||||
setw -g aggressive-resize on
|
||||
|
||||
# Set the left status: Tabs (window names)
|
||||
set -g status-left ""
|
||||
setw -g automatic-rename off
|
||||
set-hook -g after-new-window "run-shell '~/.config/tmux/tmux-rename-window.sh | xargs tmux rename-window'"
|
||||
set-hook -g pane-focus-in "run-shell '~/.config/tmux/tmux-rename-window.sh | xargs tmux rename-window'"
|
||||
|
||||
setw -g window-status-format "#[bg=#171B24,fg=#CCCAC2] #[bold]#I #[default] #[fg=#73D0FF]#W #[default]"
|
||||
setw -g window-status-current-format "#[bg=#757B84,fg=#EFEDE7] #[bold]#I #[default] #[fg=#FFAD66]#W #[default]"
|
||||
|
||||
# Set the right status: Battery, date and time, session name
|
||||
set -g status-right "#($HOME/.config/tmux/tmux-status-right.sh) | #S#[default]"
|
||||
|
||||
set -g status-bg "#171B24"
|
||||
set -g status-style bold
|
||||
|
||||
# set -g @catppuccin_flavour "macchiato"
|
||||
# set -g @catppuccin_status_background "#1e2030"
|
||||
# set -g @plugin "catppuccin/tmux"
|
||||
|
||||
set -g @plugin "tmux-plugins/tpm"
|
||||
run "~/dev/git/tpm/tpm"
|
||||
5
tmux/tmux-create-session.sh
Executable file
5
tmux/tmux-create-session.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/zsh
|
||||
|
||||
session_name=$1
|
||||
tmux new-session -d -s $session_name
|
||||
tmux switch-client -t $session_name
|
||||
45
tmux/tmux-fuzzy-find-session.sh
Executable file
45
tmux/tmux-fuzzy-find-session.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/zsh
|
||||
|
||||
# Run fzf-tmux in the background and serialize the input
|
||||
(
|
||||
current_session=$(tmux display-message -p '#S')
|
||||
selected=$(tmux list-sessions -F '#S' | grep -v "$current_session" | fzf-tmux -p --expect=enter,del --header="Tmux Sessions (Ent/Del)")
|
||||
echo "$selected" > /tmp/fzf-tmux-target
|
||||
tmux refresh-client -S
|
||||
) &
|
||||
|
||||
# Give some time for fzf to initiate and display
|
||||
sleep 0.1
|
||||
tmux refresh-client -S
|
||||
|
||||
# Wait for the fzf-tmux process to complete
|
||||
wait
|
||||
|
||||
# Read the serialized input
|
||||
selected=$(cat /tmp/fzf-tmux-target)
|
||||
rm /tmp/fzf-tmux-target
|
||||
key=$(head -n1 <<< "$selected")
|
||||
target=$(tail -n +2 <<< "$selected")
|
||||
|
||||
# Check the pressed key and take appropriate action
|
||||
case "$key" in
|
||||
enter)
|
||||
if [ -n "$target" ]; then
|
||||
tmux switch-client -t "$target"
|
||||
tmux display-message "Switched to session: $target"
|
||||
else
|
||||
tmux display-message "No session selected"
|
||||
fi
|
||||
;;
|
||||
del)
|
||||
if [ -n "$target" ]; then
|
||||
tmux kill-session -t "$target"
|
||||
tmux display-message "Deleted session: $target"
|
||||
else
|
||||
tmux display-message "No session selected"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
tmux display-message "Action cancelled"
|
||||
;;
|
||||
esac
|
||||
14
tmux/tmux-move-pane.sh
Executable file
14
tmux/tmux-move-pane.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/zsh
|
||||
|
||||
source_pane=$(tmux display-message -p '#{pane_id}')
|
||||
target_window=$1
|
||||
|
||||
window_exists=$(tmux list-windows -F '#I' | grep "^$target_window$")
|
||||
|
||||
if [ -z "$window_exists" ]; then
|
||||
tmux break-pane -d -t $target_window
|
||||
else
|
||||
target_pane=$(tmux list-panes -t $target_window -F '#{pane_id}' | sort | tail -n 1)
|
||||
tmux join-pane -d -s $source_pane -t $target_pane
|
||||
tmux select-layout -t $target_window main-vertical
|
||||
fi
|
||||
44
tmux/tmux-rename-window.sh
Executable file
44
tmux/tmux-rename-window.sh
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/zsh
|
||||
# program blacklist
|
||||
# program=$(
|
||||
# ps -o comm= -t "$(tmux display-message -p '#{pane_tty}')" 2>/dev/null \
|
||||
# | grep -v '^ps$' \
|
||||
# | grep -v 'tmux-rename-window' \
|
||||
# | grep -v 'tail' \
|
||||
# | grep -v 'head' \
|
||||
# | grep -v 'grep' \
|
||||
# | grep -v 'find' \
|
||||
# | grep -v 'rg' \
|
||||
# | grep -v 'jq' \
|
||||
# | grep -v 'perl' \
|
||||
# | grep -v 'fzf' \
|
||||
# | grep -v 'bat' \
|
||||
# | grep -v 'cat' \
|
||||
# | grep -v 'tldr' \
|
||||
# | grep -v 'man' \
|
||||
# | tail -n1
|
||||
# )
|
||||
|
||||
# Fallback if empty:
|
||||
# [[ -z "$program" ]] && program="zsh"
|
||||
|
||||
# Get the current working directory
|
||||
cwd=$(tmux display-message -p '#{pane_current_path}')
|
||||
|
||||
# If the program is zsh (or bash, etc.), show dir name
|
||||
# if [[ "$program" == "zsh" || "$program" == "bash" || "$program" == "sh" ]]; then
|
||||
[[ "$cwd" == "$HOME" ]] && dirname="~" || dirname=$(basename "$cwd")
|
||||
name="$dirname/"
|
||||
# else
|
||||
# name="$program"
|
||||
# fi
|
||||
|
||||
# Now do your truncation/padding
|
||||
MAX_WIDTH=15
|
||||
if [ "${#name}" -gt "$MAX_WIDTH" ]; then
|
||||
truncated="${name:0:$(($MAX_WIDTH-2))}…/"
|
||||
echo "$truncated"
|
||||
else
|
||||
echo "$name"
|
||||
fi
|
||||
|
||||
13
tmux/tmux-set-resize-mode.sh
Executable file
13
tmux/tmux-set-resize-mode.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/zsh
|
||||
|
||||
desired_state=$1
|
||||
current_state=$(tmux show-environment -g @resize_mode 2>/dev/null | cut -d '=' -f 2)
|
||||
|
||||
[ "$current_state" = "$desired_state" ] && exit 0
|
||||
|
||||
tmux set -g @tmux_resize_mode $desired_state
|
||||
if [ "$desired_state" = "1" ]; then
|
||||
tmux display-message "Resize mode ON"
|
||||
else
|
||||
tmux display-message "Resize mode OFF"
|
||||
fi
|
||||
15
tmux/tmux-status-right.sh
Executable file
15
tmux/tmux-status-right.sh
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
format_for_tmux() {
|
||||
fg="#1F2430"
|
||||
bg="#73D0FF"
|
||||
text_col="#CCCAC2"
|
||||
echo $1 | awk -v bg="$bg" -v fg="$fg" -v text_col="$text_col" '{printf("#[default]#[fg="bg"]#[default]#[bg="bg", fg="fg"]%s#[default]#[fg="bg"]#[default]#[fg="text_col"] %s", substr($0, 1, 1), substr($0, 2))}'
|
||||
}
|
||||
|
||||
battery_result=$($HOME/.config/confutils/get-battery.sh)
|
||||
|
||||
space=" "
|
||||
session=$(format_for_tmux "#S")
|
||||
battery=$(format_for_tmux "$battery_result")
|
||||
calendar=$(format_for_tmux " $(date +"%a %b %d")")
|
||||
|
||||
echo $session$space$battery$space$calendar
|
||||
Loading…
Add table
Add a link
Reference in a new issue