aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tmux/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to 'tmux/.local/bin')
-rwxr-xr-xtmux/.local/bin/tmux-sessionizer7
-rwxr-xr-xtmux/.local/bin/tmux-sessions29
-rwxr-xr-xtmux/.local/bin/tmux-ssh13
3 files changed, 25 insertions, 24 deletions
diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer
index 9238b43..7f0a4af 100755
--- a/tmux/.local/bin/tmux-sessionizer
+++ b/tmux/.local/bin/tmux-sessionizer
@@ -4,14 +4,9 @@
if [ "$#" -eq 0 ]; then
PREVIEW_CMD='sel={}; less ${sel:-{q}} 2>/dev/null'
- lines=$(tmux display -p "#{pane_height}")
- columns=$(tmux display -p "#{pane_width}")
- WIDTH=$([ "$columns" -gt "120" ] && printf %s "120" || printf %s "90%")
- HEIGHT=$([ "$lines" -gt "40" ] && printf %s "40" || printf %s "90%")
-
# shellcheck disable=2046
set -- $(projectr ~/dkr ~/pkg ~/src ~/.dotfiles --git --max-depth=3 | sed "\|^$(tmux display -p '#{session_path}')\$|d" |
- fzf-tmux -p "$WIDTH,$HEIGHT" -- --tac --multi --print-query -d/ --with-nth -1 \
+ fzf-tmux "$FZF_TMUX_OPTS" -- --tac --multi --print-query -d/ --with-nth -1 \
--preview-window='right,75%,<80(up,75%,border-bottom)' --preview="$PREVIEW_CMD" |
tr -s '\n' ' ') && [ $# -gt 1 ] && shift
fi
diff --git a/tmux/.local/bin/tmux-sessions b/tmux/.local/bin/tmux-sessions
index 4b68929..6d04f5f 100755
--- a/tmux/.local/bin/tmux-sessions
+++ b/tmux/.local/bin/tmux-sessions
@@ -1,11 +1,22 @@
-#!/usr/bin/env bash
+#!/bin/sh
-[[ -n "$TMUX" ]] && change="switch-client" || change="attach-session"
+if [ "$#" -eq 0 ]; then
+ # shellcheck disable=2016,2046
+ set -- $(
+ tmux list-sessions -F '#{session_last_attached}0:#{session_name}' 2>/dev/null |
+ sort -t':' -r -k1 | cut -d':' -f2 | sed "/^$(tmux display-message -p '#S')$/d" |
+ fzf-tmux "$FZF_TMUX_OPTS" -- --select-1 --exit-0 --preview-window=right,80% --preview='tmux capture-pane -ep -t {}' \
+ --bind 'ctrl-q:execute(tmux kill-session -t{})+reload(tmux list-sessions -F "#{session_name}" 2>/dev/null |
+ sed "/$(tmux display-message -p "#S")/d" )'
+ )
+fi
-# shellcheck disable=2016
-session=$(tmux list-sessions -F '#{session_last_attached}0:#{session_name}' 2>/dev/null |
- sort -t':' -r -k1 | cut -d':' -f2 | sed "/^$(tmux display-message -p '#S')$/d" |
- fzf-tmux -p -- --select-1 --exit-0 --preview-window=right,80% --preview='tmux capture-pane -ep -t {}' \
- --bind 'ctrl-q:execute(tmux kill-session -t{})+reload(tmux list-sessions -F "#{session_name}" 2>/dev/null |
- sed "/$(tmux display-message -p "#S")/d" )') &&
- tmux $change -t "$session" || exit 0
+if [ "$#" -eq 0 ]; then
+ exit 1
+fi
+
+if [ -z "$TMUX" ]; then
+ tmux attach-session -t "$1"
+else
+ tmux switch-client -t "$1"
+fi
diff --git a/tmux/.local/bin/tmux-ssh b/tmux/.local/bin/tmux-ssh
index 0bbdc7e..335e75c 100755
--- a/tmux/.local/bin/tmux-ssh
+++ b/tmux/.local/bin/tmux-ssh
@@ -5,29 +5,24 @@
if [ "$#" -eq 0 ]; then
ATTACHED=$(tmux display -p '#{session_path}')
- lines=$(tmux display -p "#{pane_height}")
- columns=$(tmux display -p "#{pane_width}")
- WIDTH=$([ "$columns" -gt "20" ] && printf %s "20" || printf %s "90%")
- HEIGHT=$([ "$lines" -gt "15" ] && printf %s "15" || printf %s "90%")
# shellcheck disable=2046
set -- $(
grep -P '^[Hh]ost ([^*]+)$' "$HOME/.ssh/config" | grep -Po ' \K(\w+)' |
- sed "\|^$HOST\$|d" | sed "\|^${ATTACHED#SSH:}\$|d" | sort -u |
+ sed "\|^$HOST\$|d" | sed "\|^${ATTACHED#SSH_}\$|d" | sort -u |
timestamp.sh --type="ssh" --format="{}:{1}" | sort -r | cut -d':' -f2 |
- fzf-tmux -p "$WIDTH,$HEIGHT" -- --multi --print-query -d/ --with-nth -1 |
+ fzf-tmux "$FZF_TMUX_OPTS" -- --multi --print-query -d/ --with-nth -1 |
tr -s '\n' ' '
) && [ $# -gt 1 ] && shift
fi
-exit 0
while [ $# -gt 0 ]; do
ssh_host="$1"
shift
- name="SSH:$ssh_host"
+ name="SSH_$ssh_host"
if ! tmux has-session -t "$name" 2>/dev/null; then
- tmux new-session -ds "$name" ssh -t "$ssh_host" 'tmux new -As $USER'
+ tmux new-session -ds "$name" ssh -t "$ssh_host" # 'tmux new -As $USER'
fi
done