From 9c3e02ea65df34c454f7ce7bc3457d1153a16153 Mon Sep 17 00:00:00 2001 From: BoltlessEngineer Date: Thu, 14 Dec 2023 22:22:45 +0900 Subject: [PATCH] feat: add `tmux.conf` --- .tmux.conf | 35 +++++++++++++++++++++++++++++++++++ README.md | 3 +++ bin/tmux-sessionizer | 25 +++++++++++++++++++++++++ fish/config.fish | 2 ++ 4 files changed, 65 insertions(+) create mode 100644 .tmux.conf create mode 100755 bin/tmux-sessionizer diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..365e554 --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,35 @@ +set -g default-terminal "xterm-256color" +set -g set-clipboard on +set -ga terminal-overrides "vte*:XT:Ms=\\E]52;c;%p2%s\\7,xterm*:XT:Ms=\\E]52;c;%p2%s\\7" +# set -sa terminal-overrides ",xterm*:Tc" + +set -g base-index 1 +set -g status-left-length 30 + +bind-key h select-pane -L +bind-key j select-pane -D +bind-key k select-pane -U +bind-key l select-pane -R +unbind '"' +unbind % +bind-key s split-window -v +bind-key v split-window -h + +bind-key r source-file ~/.tmux.conf + +set-window-option -g mode-keys vi +bind-key -T copy-mode-vi v send-keys -X begin-selection +bind-key -T copy-mode-vi V send-keys -X select-line +bind-key -T copy-mode-vi y send-keys -X copy-selection +bind-key -T copy-mode-vi r send-keys -X rectangle-toggle +bind-key -T copy-mode-vi i send-keys -X cancel +bind-key -T copy-mode-vi C-c send-keys -X cancel + +bind-key C-j run-shell "tmux neww -n 'sessionizer' ~/.dotfiles/bin/tmux-sessionizer" + +# bind-key C-j new-window -n "session-switcher" "\ +# tmux list-sessions |\ +# sed -E 's/:.*$//' |\ +# grep -v \"^$(tmux display-message -p '#S')\$\" |\ +# fzf |\ +# xargs tmux switch-client -t" diff --git a/README.md b/README.md index 07781c1..654ae73 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ ln -shf ./nvim ~/.config/nvim # install fish config ln -shf ./fish ~/.config/fish +# copy tmux config +ln -shf ./tmux.conf ~/.tmux.conf + # install lf config ln -shf ./lf ~/.config/lf diff --git a/bin/tmux-sessionizer b/bin/tmux-sessionizer new file mode 100755 index 0000000..2e9645d --- /dev/null +++ b/bin/tmux-sessionizer @@ -0,0 +1,25 @@ +#!/bin/bash + +if [[ $# -eq 1 ]]; then + selected=$1 +else + selected=$(find ~/projects ~/repo ~ -mindepth 1 -maxdepth 1 -type d | fzf) +fi + +if [[ -z $selected ]]; then + exit 0 +fi + +selected_name=$(basename "$selected" | tr . _) +tmux_running=$(pgrep tmux) + +if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then + tmux new-session -s $selected_name -c $selected + exit 0 +fi + +if ! tmux has-session -t=$selected_name 2> /dev/null; then + tmux new-session -ds $selected_name -c $selected +fi + +tmux switch-client -t $selected_name diff --git a/fish/config.fish b/fish/config.fish index 981e7dc..558b740 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -10,6 +10,8 @@ if status is-interactive alias ll="exa -lh --no-user" alias la="exa -lha --git --no-user" alias nv="foreground_nvim" + alias gs="git status" + alias gb="git checkout" alias gr="gh repo clone" alias glz="lazygit" -- 2.51.2