From 90662b5400bc76a7588d2b2053d57ff2070a3212 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 25 Mar 2026 08:45:21 +0200 Subject: Update --- fish/conf.d/tmputils.fish | 3 +++ fish/conf.d/tmux.fish | 66 +++++++---------------------------------------- tmux/tmux.conf | 8 +++--- 3 files changed, 16 insertions(+), 61 deletions(-) diff --git a/fish/conf.d/tmputils.fish b/fish/conf.d/tmputils.fish index 931fe45..938499f 100644 --- a/fish/conf.d/tmputils.fish +++ b/fish/conf.d/tmputils.fish @@ -67,3 +67,6 @@ function tmpfile end abbr -a cdtmp "cd $TMPUTILS_DIR" +abbr -a tmpn tmpnew +abbr -a temp tmpnew +abbr -a tmp tmpnew diff --git a/fish/conf.d/tmux.fish b/fish/conf.d/tmux.fish index e336c88..707bd24 100644 --- a/fish/conf.d/tmux.fish +++ b/fish/conf.d/tmux.fish @@ -1,5 +1,3 @@ -set -gx TMUX_FZF_GIT_INDEX ~/git/.index - function _tmux::cleanup_default tmux list-sessions | string match -r '^T.*: ' | string match -v -r attached | string split ':' | while read -l s echo "Killing $s" @@ -28,70 +26,24 @@ function tmux::new end function tmux::project - set -l filter - if test (count $argv) -eq 0 set -l git_root (basename (git rev-parse --show-toplevel 2>/dev/null)) if test -n "$git_root" tmux::attach (basename $git_root) return - else - set filter . end - else - set filter $argv[1] + echo "tp: no argument given and not in a git repo" + return 1 end - set -l git_dir ~/git - set -l tmp_dir $TMPUTILS_DIR - - set -l index_age 0 - if test -f $TMUX_FZF_GIT_INDEX - if test (uname) = Darwin - set $TMUX_FZF_GIT_INDEX_age (math (date +%s) - (stat -f %m $TMUX_FZF_GIT_INDEX)) - else - set $TMUX_FZF_GIT_INDEX_age (math (date +%s) - (stat -c %Y $TMUX_FZF_GIT_INDEX)) - end - end - if test $index_age -gt 86400 - rm $TMUX_FZF_GIT_INDEX + set -l dir (zoxide query -i $argv[1] 2>/dev/null) + if test $status -ne 0; or test -z "$dir" + echo "tp: no zoxide match for '$argv[1]'" + return 1 end - if not test -f $TMUX_FZF_GIT_INDEX - find $git_dir -maxdepth 5 -type d -name .git \ - | sed 's|/.git$||' | sed "s|$git_dir/||" \ - | grep -F -v . | grep -v gitsyncer-workdir | grep -v upstream >$TMUX_FZF_GIT_INDEX - # Add top-level directories from TMPUTILS_DIR (non-git) - if test -d $tmp_dir - for d in (ls $tmp_dir) - if test -d $tmp_dir/$d - echo "tmp/$d" >>$TMUX_FZF_GIT_INDEX - end - end - end - end - - set -l matches (grep "$filter" $TMUX_FZF_GIT_INDEX) - set -l session - if test (count $matches) -eq 1 - set session $matches[1] - else - set session (printf "%s\n" $matches | fzf) - end - if string match -r '^tmp/' $session - set -l real (string replace -r '^tmp/' '' $session) - cd $TMPUTILS_DIR/$real - else if test -d $git_dir/$session - cd $git_dir/$session - end - tmux::attach $session -end - -function tmux::project::reindex - if test -f $TMUX_FZF_GIT_INDEX - rm $TMUX_FZF_GIT_INDEX - end - tmux::project $argv + cd $dir + tmux::attach (basename $dir) end function tmux::attach @@ -157,9 +109,9 @@ alias tx 'tmux::remote' alias tl 'tmux::search' alias tssh 'tmux::cluster_ssh' alias tp 'tmux::project' -alias tpr 'tmux::project::reindex' alias notes 'cd ~/Notes; tmux::attach notes' alias N 'cd ~/Notes; tmux::attach notes' alias bar 'tmux::new bar' alias baz 'tmux::new baz' alias bay 'tmux::new bay' +abbr -a tkt "tmux list-sessions -F '#{session_name}' | grep -- '-tmp-' | xargs -I{} tmux kill-session -t '{}'" diff --git a/tmux/tmux.conf b/tmux/tmux.conf index f96cc7c..0a673ef 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -17,11 +17,11 @@ bind-key J resize-pane -D 5 bind-key K resize-pane -U 5 bind-key L resize-pane -R 5 -bind-key g popup -E -w 99% -h 99% -d '#{pane_current_path}' lazygit -bind-key f popup -E -w 99% -h 99% -d '#{pane_current_path}' ranger +bind-key g popup -E -w 99% -h 99% -d '#{pane_current_path}' "fish -c 'tmux new-session -A -s (basename (pwd))-tmp-lazygit lazygit'" +bind-key f popup -E -w 99% -h 99% -d '#{pane_current_path}' "fish -c 'tmux new-session -A -s (basename (pwd))-tmp-ranger ranger'" bind-key e run-shell -b "cd '#{pane_current_path}' && hexai-tmux-edit --pane '#{pane_id}'" -bind-key N popup -E -w 99% -h 99% hx ~/Notes -bind-key t popup -E -w 99% -h 99% hx fish +bind-key N popup -E -w 99% -h 99% -d ~/Notes "fish -c 'tmux::attach notes'" +bind-key t popup -E -w 99% -h 99% -d '#{pane_current_path}' "fish -c 'tmux::attach (basename (pwd))-tmp-scratch'" # bind-key b break-pane -d bind-key c new-window -c '#{pane_current_path}' -- cgit v1.2.3