summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-01-13 19:04:22 -0500
committerBenjamin Chausse <benjamin@chausse.xyz>2024-01-13 19:04:22 -0500
commit719c3734ff2d247b386e398b4cf98aa62c6f6cc0 (patch)
tree324522598ff677ee092e4e1047304dcc7d5f7567
parentbf434758d9c60c323d571bc1e2e329edaad06fa3 (diff)
Cool new sshchoose prompt
-rw-r--r--.config/sxhkd/sxhkdrc3
-rwxr-xr-x.local/bin/sshchoose8
-rwxr-xr-x.local/bin/tmux-r11
-rwxr-xr-x.local/bin/tmux-ssh17
4 files changed, 31 insertions, 8 deletions
diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc
index 90dad96..a3163f4 100644
--- a/.config/sxhkd/sxhkdrc
+++ b/.config/sxhkd/sxhkdrc
@@ -151,6 +151,9 @@ super + a
## Terminal Shell
super + shift + a
dropdowntoggle shell tmux-shell
+## Terminal remote session (ssh)
+super + r
+ sshchoose
#-# Prompts (dmenu) #-#
## Application Launcher
diff --git a/.local/bin/sshchoose b/.local/bin/sshchoose
index 6b884c6..378ab73 100755
--- a/.local/bin/sshchoose
+++ b/.local/bin/sshchoose
@@ -1,6 +1,10 @@
#!/bin/sh
-choice="$(pass ls ssh/ | sed '1d;s/^.*\s//g' | fzf)"
+# user@host are stored in pass under the ssh/ directory
+available="$(pass ls ssh/ | sed '/^ssh$/d;s/.*─\s//' | sed 's/\x1b\[[0-9;]*m//g')"
-ssh "$(pass ssh/$choice)"
+choice="$(echo "$available" | dmenu -p " Choose session")"
+addr="$(pass "ssh/$choice")"
+
+dropdowntoggle "ssh-$choice" "tmux-ssh" "choice" "$addr"
diff --git a/.local/bin/tmux-r b/.local/bin/tmux-r
index 14dd08a..6b4819c 100755
--- a/.local/bin/tmux-r
+++ b/.local/bin/tmux-r
@@ -1,5 +1,5 @@
#!/bin/sh
-# This script ensures that i3 will spawn a youtube tui.
+
session="R"
# Check if the session exists, discarding output
@@ -7,12 +7,11 @@ session="R"
tmux has-session -t $session 2>/dev/null
if [ $? != 0 ]; then
- # Set up your session
- tmux new-session -d -s "$session" R -q --no-save
- # R -q --no-save
- # ([ -e /usr/bin/R ] && R -q --no-save) || python -q
+ # Set up your session
+ tmux new-session -d -s "$session" R -q --no-save
+ # R -q --no-save
+ # ([ -e /usr/bin/R ] && R -q --no-save) || python -q
fi
# Attach to created session
tmux attach-session -t $session
-
diff --git a/.local/bin/tmux-ssh b/.local/bin/tmux-ssh
new file mode 100755
index 0000000..f47e0ac
--- /dev/null
+++ b/.local/bin/tmux-ssh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Usage: tmux-ssh <session-name> user@ip
+
+session="ssh-$1"
+
+tmux has-session -t $session 2>/dev/null
+
+if [ $? != 0 ]; then
+ # Set up your session
+ tmux new-session -d -s "$session" "ssh $2"
+ # R -q --no-save
+ # ([ -e /usr/bin/R ] && R -q --no-save) || python -q
+fi
+
+# Attach to created session
+tmux attach-session -t "$session"