Add tmux config and replace zellij with tmux in zshrc.
Zhrc also has some light refactoring, and has added a zsh local file which gets sourced if it exists, useful for adding local environment variables
This commit is contained in:
parent
6ebb641656
commit
d094fce66d
6 changed files with 186 additions and 6 deletions
5
home/.config/tmux/tmux-create-session.sh
Executable file
5
home/.config/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
home/.config/tmux/tmux-fuzzy-find-session.sh
Executable file
45
home/.config/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
home/.config/tmux/tmux-move-pane.sh
Executable file
14
home/.config/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
|
||||
13
home/.config/tmux/tmux-set-resize-mode.sh
Executable file
13
home/.config/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
|
||||
Loading…
Add table
Add a link
Reference in a new issue