Compare commits

..

3 Commits

Author SHA1 Message Date
a795eb8eec tmux: Use sesh for tmux session management
The zsh tmux plugin has been removed and instead fzf is shown to select
a session.
2025-09-11 01:48:51 +02:00
a5febcddf6 fzf: Improve border label 2025-09-11 01:47:32 +02:00
2250a56599 zsh: Improve how command availability is detected 2025-09-11 01:46:54 +02:00
4 changed files with 40 additions and 14 deletions

View File

@@ -73,3 +73,5 @@ bind-key -n M-7 select-window -t 7
bind-key -n M-8 select-window -t 8 bind-key -n M-8 select-window -t 8
bind-key -n M-9 select-window -t 9 bind-key -n M-9 select-window -t 9
bind-key -n M-0 select-window -t 10 bind-key -n M-0 select-window -t 10
bind-key "a" run-shell "which sesh-select"

17
zsh/dot-local/bin/sesh-select Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env zsh
exec </dev/tty
exec <&1
local session
session=$(sesh list -id | fzf-tmux -p 70%,60% \
--no-sort --ansi --border-label ' Select session ' --prompt '⚡ ' \
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
--bind 'btab:down,tab:up' \
--bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list -id)' \
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t -id)' \
--bind 'ctrl-g:change-prompt(⚙️ )+reload(sesh list -c -id)' \
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z -id)' \
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
--bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡ )+reload(sesh list -id)')
[[ -z "$session" ]] && return
sesh connect $session

View File

@@ -22,7 +22,6 @@ plugins=(
# Disabled because the highlighting conflicts with autosuggestions # Disabled because the highlighting conflicts with autosuggestions
# history-substring-search # history-substring-search
vi-mode vi-mode
tmux
colored-man-pages colored-man-pages
command-not-found command-not-found
zsh-autopair zsh-autopair
@@ -43,10 +42,6 @@ VI_MODE_SET_CURSOR=true
# Might cause issues? # Might cause issues?
KEYTIMEOUT=1 KEYTIMEOUT=1
ZSH_TMUX_AUTOSTART=true
ZSH_TMUX_AUTOCONNECT=false
ZSH_TMUX_FIXTERM=true
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
autoload -U compinit && compinit autoload -U compinit && compinit
source "$ZSH/oh-my-zsh.sh" source "$ZSH/oh-my-zsh.sh"
@@ -60,12 +55,12 @@ export EDITOR=nvim
alias cl="clear" alias cl="clear"
if hash bat 2>/dev/null; then if (( $+commands[hash] )); then
export BAT_THEME="gruvbox-dark" export BAT_THEME="gruvbox-dark"
alias cat=bat alias cat=bat
fi fi
if hash devcontainer 2>/dev/null; then if (( $+commands[devcontainer] )); then
dc() { dc() {
ORIG_DIR="$PWD" ORIG_DIR="$PWD"
while [[ "$PWD" != / ]] ; do while [[ "$PWD" != / ]] ; do
@@ -92,7 +87,7 @@ if hash devcontainer 2>/dev/null; then
} }
fi fi
if hash pnpm 2>/dev/null; then if (( $+commands[pnpm] )); then
export PNPM_HOME="/home/tim/.local/share/pnpm" export PNPM_HOME="/home/tim/.local/share/pnpm"
case ":$PATH:" in case ":$PATH:" in
*":$PNPM_HOME:"*) ;; *":$PNPM_HOME:"*) ;;
@@ -110,22 +105,22 @@ export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS'
--prompt="> " --marker="◆" --pointer=">" --separator="─" --prompt="> " --marker="◆" --pointer=">" --separator="─"
--scrollbar="│" --info="right"' --scrollbar="│" --info="right"'
if hash fd 2>/dev/null; then if (( $+commands[fd] )); then
export FZF_DEFAULT_COMMAND="fd --type f --strip-cwd-prefix" export FZF_DEFAULT_COMMAND="fd --type f --strip-cwd-prefix"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
fi fi
if hash fzf 2>/dev/null; then if (( $+commands[fzf] )); then
source <(fzf --zsh) source <(fzf --zsh)
if hash paru 2>/dev/null; then if (( $+commands[paru] )); then
function pi { function pi {
paru -Slq | fzf -q "$1" --border-label="Packages" --multi --preview 'paru -Si {1} --color=always' | xargs -ro paru -S paru -Slq | fzf -q "$1" --border-label=" Install package " --multi --preview 'paru -Si {1} --color=always' | xargs -ro paru -S
} }
fi fi
fi fi
export _ZO_FZF_OPTS="--tmux" export _ZO_FZF_OPTS="--tmux"
if hash zoxide 2>/dev/null; then if (( $+commands[zoxide] )); then
eval "$(zoxide init zsh --cmd cd)" eval "$(zoxide init zsh --cmd cd)"
fi fi
@@ -142,3 +137,15 @@ for km in viopp visual; do
bindkey -M $km $c select-bracketed bindkey -M $km $c select-bracketed
done done
done done
ZSH_TMUX_AUTOSTART=true
if (( $+commands[tmux] )); then
if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" && -z "$INTELLIJ_ENVIRONMENT_READER" && -z "$ZED_TERM" ]]; then
if (( $+commands[sesh] )); then
sesh-select
else
tmux new-session
fi
exit
fi
fi