diff --git a/chezmoi/.chezmoiexternal.toml b/chezmoi/.chezmoiexternal.toml index 58916b9..192569c 100644 --- a/chezmoi/.chezmoiexternal.toml +++ b/chezmoi/.chezmoiexternal.toml @@ -18,3 +18,9 @@ type = "git-repo" url = "https://github.com/b3nj5m1n/xdg-ninja.git" refreshPeriod = "168h" + +[".local/bin/sesh"] + type = "archive-file" + url = "https://github.com/joshmedeski/sesh/releases/latest/download/sesh_Linux_x86_64.tar.gz" + path = "sesh" + refreshPeriod = "168h" diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/sessions.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/sessions.lua index aba169d..9878d89 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/sessions.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/sessions.lua @@ -5,7 +5,7 @@ return { ---@diagnostic disable-next-line: missing-fields require("auto-session").setup({ log_level = "error", - auto_session_suppress_dirs = { "~/", "~/Downloads", "/", "~/.config/**" }, + auto_session_suppress_dirs = { "~/", "~/Downloads", "/", "~/.config/**", "~/.local/share/chezmoi/" }, bypass_session_save_file_types = { "NeogitStatus", "Lazy", diff --git a/chezmoi/dot_config/sesh/sesh.toml b/chezmoi/dot_config/sesh/sesh.toml new file mode 100644 index 0000000..23c1186 --- /dev/null +++ b/chezmoi/dot_config/sesh/sesh.toml @@ -0,0 +1,14 @@ +[[session]] +name = "Downloads" +path = "~/Downloads" +startup_command = "ls" + +[[session]] +name = "Dotfiles" +path = "~/.local/share/chezmoi/" +startup_command = "nvim -c ':Telescope find_files'" + +[[session]] +name = "SSH" +path = "~/.ssh/" +startup_command = "nvim config" diff --git a/chezmoi/dot_config/tmux/tmux.conf b/chezmoi/dot_config/tmux/tmux.conf index 5ca5233..e731eae 100644 --- a/chezmoi/dot_config/tmux/tmux.conf +++ b/chezmoi/dot_config/tmux/tmux.conf @@ -15,6 +15,7 @@ bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "wl-copy" set -sg escape-time 0 set-option -g focus-events on set-option -g renumber-windows on +set -g detach-on-destroy off # don't exit from tmux when closing a session # Yazi need this config to show image preview set -g allow-passthrough on @@ -88,7 +89,6 @@ set -g @plugin 'christoomey/vim-tmux-navigator' set -g @plugin 'sainnhe/tmux-fzf' set -g @plugin 'tmux-plugins/tmux-resurrect' set -g @plugin 'tmux-plugins/tmux-continuum' -set -g @plugin '27medkamal/tmux-session-wizard' ## Plugin Config @@ -108,7 +108,9 @@ set -g @resurrect-processes 'vi vim nvim man "~pnpm dev->pnpm dev *"' TMUX_FZF_LAUNCH_KEY="w" TMUX_FZF_OPTIONS="-p -w 80% -h 60% -m" + # Tmux Management -set -g @session-wizard 'f' +bind-key "f" run-shell "fzf-tmux-sessions" + bind-key "F" run-shell -b "$HOME/.config/tmux/plugins/tmux-fzf/scripts/session.sh switch" # bind-key "F" run-shell -b "$HOME/.config/tmux/plugins/tmux-fzf/scripts/window.sh switch" diff --git a/chezmoi/dot_config/zsh/aliases/aliases.zsh b/chezmoi/dot_config/zsh/aliases/aliases.zsh index a0e766d..d0b7088 100644 --- a/chezmoi/dot_config/zsh/aliases/aliases.zsh +++ b/chezmoi/dot_config/zsh/aliases/aliases.zsh @@ -44,6 +44,8 @@ alias \ pco='podman compose' \ pps="podman ps --format 'table {{.ID}}\t{{.Names}}\t{{.State}}\t{{.Status}}\t{{.RunningFor}}'" +alias tm="fzf-tmux-sessions" + # Misc alias \ reload='exec $SHELL -l' diff --git a/chezmoi/dot_config/zsh/functions/tmux.zsh b/chezmoi/dot_config/zsh/functions/tmux.zsh deleted file mode 100644 index 114137b..0000000 --- a/chezmoi/dot_config/zsh/functions/tmux.zsh +++ /dev/null @@ -1,41 +0,0 @@ -SEPARATOR=" │ " -FZF_SEPARATOR="│" # Same character, without whitespaces - -format_values() { - values="$1" - shift - divider="$1" - shift - echo -e "$(echo "$values" | column --table --separator $divider --output-separator $SEPARATOR)" -} - -tmux_switch_or_create() { - target=$1 - [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" - - tmux $change -t "$target" 2>/dev/null || (tmux new-session -d -s $target && tmux $change -t "$target"); return -} - -# tm - create new tmux session, or switch to existing one. Works from within tmux too. (@bag-man) -# `tm` will allow you to select your tmux session via fzf. -# `tm irc` will attach to the irc session (if it exists), else it will create it. - -tm() { - [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" - if [ $1 ]; then - tmux $change -t "$1" 2>/dev/null || (tmux new-session -d -s $1 && tmux $change -t "$1"); return - fi - session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0 --select-1) && tmux $change -t "$session" || echo "No sessions found." -} - -ta() { - export START_DIRECTORY="$(z -l 2>&1 | fzf --height 40% --nth 2.. --reverse --inline-info +s --tac --query "${*##-* }" | sed 's/^[0-9,.]* *//')" - - if [[ -z START_DIRECTORY ]]; then - exit 0 - fi - - export SESSION_NAME="$(basename $START_DIRECTORY)" - - tmuxp load $(fd -e yml . ~/.config/tmuxp | fzf) -} diff --git a/scripts/fzf-tmux-sessions b/scripts/fzf-tmux-sessions new file mode 100755 index 0000000..ebfc8e0 --- /dev/null +++ b/scripts/fzf-tmux-sessions @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +sesh connect "$( + sesh list | fzf-tmux -p 55%,60% \ + --no-sort --border-label ' sesh ' --prompt '⚡ ' \ + --header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^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-g:change-prompt(⚙️ )+reload(sesh list -c)' \ + --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)' +)"