fix: update tmux

This commit is contained in:
gwg313 2024-02-07 20:46:31 -05:00
parent 6edcf42c52
commit c175a36a13
Signed by: gwg313
GPG key ID: 60FF63B4826B7400
3 changed files with 127 additions and 169 deletions

View file

@ -0,0 +1,28 @@
tmux:
symbols:
branch: " "
hashprefix: ":"
ahead: " "
behind: " "
staged: " "
conflict: "󰕚 "
untracked: "󱀶 "
modified: " "
stashed: " "
clean: " "
insertions: " "
deletions: " "
styles:
state: "#[fg=red,nobold]"
branch: "#[fg=white,nobold]"
staged: "#[fg=green,nobold]"
conflict: "#[fg=red,nobold]"
modified: "#[fg=yellow,nobold]"
untracked: "#[fg=gray,nobold]"
stashed: "#[fg=gray,nobold]"
clean: "#[fg=green,nobold]"
divergence: "#[fg=cyan,nobold]"
layout: [branch, divergence, flags, stats, " "]
options:
branch_max_len: 0
hide_clean: true

View file

@ -1,77 +0,0 @@
#!/bin/bash
not_in_tmux() {
[ -z "$TMUX" ]
}
DIR="$1"
# If no arguments are passed in, try to immediately attach or start without further input
echo "$DIR"
if [ -z "$DIR" ]; then
if not_in_tmux; then
tmux attach && exit 1 || DIR="--start"
else
exit 1
fi
fi
# If --start was passed in, immediately start a new session based on the current directory
if [ "$DIR" = "--start" ]; then
echo "Starting"
path_name="$(basename "$PWD" | tr . -)"
session_name="${path_name//./_}"
else
# Ask the user which directory to start in
_session_name=$(cd "$DIR" && find -L . -maxdepth 1 -type d -printf "%f\n" | sed "s|/||g" | fzf --reverse --header="Select project from $(basename "$DIR")")
session_name="${_session_name//./_}"
path_name="$DIR/$_session_name"
fi
echo "Session name is \"$session_name\""
echo "Path name is \"$path_name\""
if [ -z "$session_name" ]; then
# Operation cancelled by user
exit 1
fi
session_exists() {
# Check if the $session_name exists
tmux has-session -t "=$session_name"
}
create_detached_session() {
if [ "$DIR" = "--start" ]; then
(TMUX=''
tmux new-session -Ad -s "$session_name" -c "$path_name"
)
else
(TMUX=''
tmux new-session -Ad -s "$session_name" -c "$path_name"
# tmux split-window -vb -t "$session_name" -c "$path_name" -p 70
tmux send-keys -t "$session_name" "nvim '+Telescope find_files'" Enter
)
fi
}
create_if_needed_and_attach() {
if not_in_tmux; then
tmux new-session -As "$session_name" -c "$path_name"
else
if ! session_exists; then
create_detached_session
fi
tmux switch-client -t "$session_name"
fi
}
attach_to_first_session() {
first_session_name=$(tmux list-sessions -F "#{session_name}" | head -n 1)
if [ -n "$first_session_name" ]; then
tmux attach -t "$first_session_name"
tmux choose-tree -Za
fi
}
create_if_needed_and_attach || attach_to_first_session

View file

@ -28,15 +28,16 @@
# New Theme
set -g status-interval 3 # update the status bar every 3 seconds
set -g status-left "#[fg=blue,bold,bg=#${config.lib.stylix.colors.base00}]#S "
set -g status-right "#[fg=#${config.lib.stylix.colors.base07},bold,bg=#${config.lib.stylix.colors.base00}]%a %Y-%m-%d 󱑒 %l:%M %p"
set -ga status-right "#($HOME/.config/tmux/scripts/cal.sh)"
#set -g status-left "#[fg=blue,bold,bg=#${config.lib.stylix.colors.base00}] #S  "
set -ga status-left " #[fg=blue,nobold]#(gitmux -cfg $HOME/.config/tmux/gitmux.yml)"
set -g status-right ""
set -g status-justify left
set -g status-left-length 200 # increase length (from 10)
set -g status-right-length 200 # increase length (from 10)
set -g status-position top # macOS / darwin style
set -g status-style 'bg=#${config.lib.stylix.colors.base00}' # transparent
set -g window-status-current-format '#[fg=magenta,bg=#${config.lib.stylix.colors.base00}]#I#W#{?window_zoomed_flag,(),} '
set -g window-status-current-format '#[fg=magenta,bg=#${config.lib.stylix.colors.base00}]#I👉#W#{?window_zoomed_flag,(),} '
set -g window-status-format '#[fg=gray,bg=#${config.lib.stylix.colors.base00}] #I #W'
set -g window-status-last-style 'fg=white,bg=black'
set -g message-command-style bg=default,fg=yellow
@ -52,10 +53,13 @@
set-option -g status-position top
bind-key g display-popup -h 95% -w 95% -E 'lazygit'
bind-key t display-popup -h 95% -w 95% -E "${pkgs.htop}/bin/htop"
bind-key x kill-pane
bind C-g display-popup -E "tat ~/Projects"
#bind-key g display-popup -h 95% -w 95% -E 'lazygit'
bind -N "+g lazygit " g new-window -c "#{pane_current_path}" -n "🌳" "lazygit 2> /dev/null"
bind -N "+G gh-dash " G new-window -c "#{pane_current_path}" -n "😺" "gh-dash 2> /dev/null"
bind-key t display-popup -h 95% -w 95% -E "${pkgs.htop}/bin/htop"
bind-key e send-keys "tmux capture-pane -p -S - | nvim -c 'set buftype=nofile' +" Enter
bind -n M-g display-popup -E "tmux new-session -A -s scratch"
@ -128,12 +132,18 @@
fzf --reverse -m --header=kill-session |\
xargs -I {} tmux kill-session -t {}"
bind C-j display-popup -E "\
tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\
sed '/^$/d' |\
fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\
xargs tmux switch-client -t"
bind-key "T" run-shell "sesh connect $(
sesh list -tz | fzf-tmux -p 55%,60% \
--no-sort --border-label ' sesh ' --prompt ' ' \
--header ' ^a all ^t tmux ^x zoxide ^f find' \
--bind 'tab:down,btab:up' \
--bind 'ctrl-a:change-prompt( )+reload(sesh list)' \
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t)' \
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z)' \
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)'
--bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt( )+reload(sesh list)'
)"
'';
};
@ -143,15 +153,12 @@
};
home.packages = [
# Open tmux for current project.
(pkgs.writeShellApplication {
name = "tat";
runtimeInputs = [pkgs.tmux pkgs.fzf];
text = builtins.readFile ./ta.sh;
})
pkgs.fzf
pkgs.gitmux
];
home.file.".config/tmux/gitmux.yml".source = ./gitmux.yml;
programs.zsh = {
shellAliases = {
tx = "tmux new -s default";