From 510346e10839934217cc0885cf724642f831212f Mon Sep 17 00:00:00 2001 From: Ibrahim Muftee Date: Fri, 22 Aug 2025 14:06:08 -0500 Subject: feat(tmux): add tmux --- dot_config/tmux/tmux.conf | 20 +++++++++++++++ dot_zshrc.tmpl | 2 +- .../bin/executable_tmux-session-dispensary.sh | 30 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 dot_config/tmux/tmux.conf create mode 100644 private_dot_local/bin/executable_tmux-session-dispensary.sh diff --git a/dot_config/tmux/tmux.conf b/dot_config/tmux/tmux.conf new file mode 100644 index 0000000..e0d060d --- /dev/null +++ b/dot_config/tmux/tmux.conf @@ -0,0 +1,20 @@ +set -a terminal-features "xterm-256color:RGB" +set -g prefix C-SPACE +set -g base-index 1 +set -g renumber-windows on +set -g mode-keys vi +set -g status-position top +set -g status-justify absolute-centre +set -g status-style "bg=default" +set -g window-status-current-style "fg=blue bg=default bold" +set -g status-right "" +set -g status-left "#S" + +bind r source-file "~/.config/tmux/tmux.conf" +bind f run-shell "tmux neww ~/.local/bin/tmux-session-dispensary.sh" + +# Vim key pane naviagtion +bind -r h select-pane -L +bind -r j select-pane -D +bind -r k select-pane -U +bind -r l select-pane -R diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 4e7cb75..5c51dab 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -93,7 +93,7 @@ bindkey -s '^o' 'lfcd\n' bindkey -s '^a' 'bc -lq\n' -bindkey -s '^f' '$(eval find $HOME/.config $HOME/code $HOME/.local/share -mindepth 1 -maxdepth 1 | fzf)\n' +bindkey -s '^f' 'tmux-session-dispensary.sh\n' bindkey '^[[P' delete-char diff --git a/private_dot_local/bin/executable_tmux-session-dispensary.sh b/private_dot_local/bin/executable_tmux-session-dispensary.sh new file mode 100644 index 0000000..ccbdbaf --- /dev/null +++ b/private_dot_local/bin/executable_tmux-session-dispensary.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +DIRS=( + "$HOME" + "$HOME/.config" + "$HOME/.local" + "$HOME/.local/share" + "$HOME/Documents" + "$HOME/Documents/Code" +) + +if [[ $# -eq 1 ]]; then + selected=$1 +else + selected=$(fd "${DIRS[@]}" --type=dir --max-depth=1 --full-path \ + | sed "s|^$HOME/||" \ + | sk -m) + [[ $selected ]] && selected="$HOME/$selected" +fi + +[[ ! $selected ]] && exit 0 + +selected_name=$(basename "$selected" | tr . _) +if ! tmux has-session -t "$selected_name"; then + tmux new-session -ds "$selected_name" -c "$selected" + tmux select-window -t "$selected_name:1" +fi + +connect_cmd=$([[ -z $TMUX ]] && echo "attach" || echo "switch-client") +tmux "$connect_cmd" -t "$selected_name" -- cgit v1.2.3