diff options
Diffstat (limited to 'tmux')
-rwxr-xr-x | tmux/.local/bin/tmux-sessionizer | 9 | ||||
-rwxr-xr-x | tmux/.local/bin/tmux-sessions | 10 | ||||
-rwxr-xr-x | tmux/.local/bin/tmux-tree | 24 | ||||
-rwxr-xr-x | tmux/.local/bin/tmux-windowizer | 10 |
4 files changed, 30 insertions, 23 deletions
diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer index 522441c..30b547e 100755 --- a/tmux/.local/bin/tmux-sessionizer +++ b/tmux/.local/bin/tmux-sessionizer @@ -3,8 +3,13 @@ if [ "$#" -eq 1 ]; then selected="$1" else - selected=$(find ~/src ~/.dotfiles -maxdepth 2 -type d -path '*/.git' -printf '%h\n' -prune | sort | - fzf-tmux -p -- -d/ --with-nth 3.. --preview="exa --tree --icons --git-ignore {}") + selected=$( + find ~/src ~/.dotfiles -maxdepth 2 -type d,f -path '*/.git' -printf '%h\n' -prune | + xargs -I{} sh -c 'git -C "{}" rev-parse HEAD &>/dev/null && + git -C "{}" --no-pager log -1 --all --format="%at:{}" 2>/dev/null || + stat -c %Y:"{}" "{}"/.git' | sort -r | cut -d':' -f2- | + fzf-tmux -p -- -d/ --with-nth -2.. --preview="exa --tree --icons --git-ignore {}" + ) fi if [ -z "$selected" ]; then diff --git a/tmux/.local/bin/tmux-sessions b/tmux/.local/bin/tmux-sessions index 68fec47..ac44580 100755 --- a/tmux/.local/bin/tmux-sessions +++ b/tmux/.local/bin/tmux-sessions @@ -2,7 +2,9 @@ [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" -session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | - fzf-tmux -p -- --reverse --exit-0 --preview='tmux-tree {} | bat --style plain') && - tmux $change -t "$session" || exit 0 - +# shellcheck disable=2016 +session=$(tmux list-sessions -F '#{session_last_attached}:#{session_name}' 2>/dev/null | + sort -r | cut -d':' -f2 | sed "/$(tmux list-panes -F '#S')/d" | + fzf-tmux -p -- --preview-window=right,80% --preview='tmux capture-pane -ep -t {}' \ + --bind 'ctrl-d:execute(tmux kill-session -t{})+reload(tmux list-sessions -F "#{session_name}" 2>/dev/null | sed "/$(tmux list-panes -F "#S")/d" )') && + tmux $change -t "$session" || exit 0 diff --git a/tmux/.local/bin/tmux-tree b/tmux/.local/bin/tmux-tree index d60bb44..600fd61 100755 --- a/tmux/.local/bin/tmux-tree +++ b/tmux/.local/bin/tmux-tree @@ -1,16 +1,16 @@ #!/usr/bin/env bash tmux ls -F'#{session_id}' | while read -r s; do - S=$(tmux ls -F'#{session_id}#{session_name}: #{T:tree_mode_format}' | grep ^"$s") - session_info=${S##$s} - session_name=$(echo "$session_info" | cut -d ':' -f 1) - if [[ -n "$1" ]] && [[ "$1" == "$session_name" ]]; then - echo -e "\033[1;34m$session_info\033[0m" - else - echo -e "\033[1m$session_info\033[0m" - fi - tmux lsw -t"$s" -F'#{window_id}' | while read -r w; do - W=$(tmux lsw -t"$s" -F'#{window_id}#{T:tree_mode_format}' | grep ^"$w") - echo " ${W##$w}" - done + S=$(tmux ls -F'#{session_id}#{session_name}: #{T:tree_mode_format}' | grep ^"$s") + session_info=${S##$s} + session_name=$(echo "$session_info" | cut -d ':' -f 1) + if [[ -n "$1" ]] && [[ "$1" == "$session_name" ]]; then + echo -e "\033[1;34m$session_info\033[0m" + else + echo -e "\033[1m$session_info\033[0m" + fi + tmux lsw -t"$s" -F'#{window_id}' | while read -r w; do + W=$(tmux lsw -t"$s" -F'#{window_id}#{T:tree_mode_format}' | grep ^"$w") + echo " ${W##$w}" + done done diff --git a/tmux/.local/bin/tmux-windowizer b/tmux/.local/bin/tmux-windowizer index 6cee8b0..81509ae 100755 --- a/tmux/.local/bin/tmux-windowizer +++ b/tmux/.local/bin/tmux-windowizer @@ -1,14 +1,14 @@ #!/usr/bin/env bash -branch_name=$(basename $1) +branch_name=$(basename "$1") session_name=$(tmux display-message -p "#S") -clean_name=$(echo $branch_name | tr "./" "__") +clean_name=$(echo "$branch_name" | tr "./" "__") target="$session_name:$clean_name" -if ! tmux has-session -t $target 2>/dev/null; then - tmux neww -dn $clean_name +if ! tmux has-session -t "$target" 2>/dev/null; then + tmux neww -dn "$clean_name" fi shift -tmux send-keys -t $target "$* +tmux send-keys -t "$target" "$* " |