From 679415792ea6240d57bff0cc170bbbb08f735b6c Mon Sep 17 00:00:00 2001 From: JirR02 Date: Fri, 24 Nov 2023 18:03:30 +0100 Subject: [PATCH] Added tmux conf and script --- .config/tmux/tmux-sessionizer-files | 17 ++++++++++++ .config/tmux/tmux-sessionizer-git | 17 ++++++++++++ .config/tmux/tmux.conf | 43 +++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100755 .config/tmux/tmux-sessionizer-files create mode 100755 .config/tmux/tmux-sessionizer-git create mode 100644 .config/tmux/tmux.conf diff --git a/.config/tmux/tmux-sessionizer-files b/.config/tmux/tmux-sessionizer-files new file mode 100755 index 0000000..5fd55df --- /dev/null +++ b/.config/tmux/tmux-sessionizer-files @@ -0,0 +1,17 @@ +#!/usr/bin/env zsh + +selected=$(find ~/ -mindepth 2 -maxdepth 2 -type d | fzf) + +selected_name=$(basename "$selected" | tr . _) + +tmux has-session -t=$selected_name 2> /dev/null + +if [[ $? -ne 0 ]]; then + TMUX='' tmux new-session -d -s "$selected_name" -c "$selected" +fi + +if [[ -z "$TMUX" ]]; then + tmux attach -t "$selected_name" +else + tmux switch-client -t "$selected_name" +fi diff --git a/.config/tmux/tmux-sessionizer-git b/.config/tmux/tmux-sessionizer-git new file mode 100755 index 0000000..26e490f --- /dev/null +++ b/.config/tmux/tmux-sessionizer-git @@ -0,0 +1,17 @@ +#!/usr/bin/env zsh + +selected=$(find ~/Projects/Private/ ~/Projects/Public/ -mindepth 1 -maxdepth 1 -type d | fzf) + +selected_name=$(basename "$selected" | tr . _) + +tmux has-session -t=$selected_name 2> /dev/null + +if [[ $? -ne 0 ]]; then + TMUX='' tmux new-session -d -s "$selected_name" -c "$selected" +fi + +if [[ -z "$TMUX" ]]; then + tmux attach -t "$selected_name" +else + tmux switch-client -t "$selected_name" +fi diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf new file mode 100644 index 0000000..c8608da --- /dev/null +++ b/.config/tmux/tmux.conf @@ -0,0 +1,43 @@ +set -g default-terminal "screen-256color" + +set -g prefix C-a +unbind C-b +bind-key C-a send-prefix + +unbind % +bind - split-window -v + +unbind '"' +bind _ split-window -h + +bind -r j resize-pane -D 5 +bind -r k resize-pane -U 5 +bind -r h resize-pane -L 5 +bind -r l resize-pane -R 5 + +bind -r m resize-pane -Z + +set-window-option -g mode-keys vi + +bind-key -T copy-mode-vi 'v' send -X begin-selection +bind-key -T copy-mode-vi 'y' send -X copy-selection + +unbind -T copy-mode-vi MouseDragEnd1Pane + +unbind r +bind -r r source-file ~/.config/tmux/tmux.conf + +bind-key -r g run-shell -b "tmux neww ~/.config/tmux/tmux-sessionizer-git" +bind-key -r f run-shell -b "tmux neww ~/.config/tmux/tmux-sessionizer-files" + +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'christoomey/vim-tmux-navigator' +set -g @plugin 'wfxr/tmux-power' +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-continuum' + +set -g @tmux_power_theme '#BD93F9' +set -g @resurrect-capture-pane-contents 'on' +set -g @continuum-restore 'on' + +run '~/.config/tmux/plugins/tpm/tpm'