summaryrefslogtreecommitdiff
path: root/arch/scripts/.local/bin/seshc.sh
diff options
context:
space:
mode:
Diffstat (limited to 'arch/scripts/.local/bin/seshc.sh')
-rw-r--r--arch/scripts/.local/bin/seshc.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/scripts/.local/bin/seshc.sh b/arch/scripts/.local/bin/seshc.sh
new file mode 100644
index 0000000..0c659d6
--- /dev/null
+++ b/arch/scripts/.local/bin/seshc.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+query="${1:-}"
+
+sessions=$(sesh list -j -t)
+
+if [[ -z "$query" ]]; then
+ name=$(jq -r '.[0].Name' <<<"$sessions")
+else
+ name=$(jq -r '.[].Name' <<<"$sessions" | fzf --filter "$query" | head -n1)
+fi
+
+if [[ -z "${name:-}" ]]; then
+ echo "${0:-}: no session matched '$query'" >&2
+ exit 1
+fi
+
+exec sesh connect "$name"