aboutsummaryrefslogtreecommitdiff
path: root/insel-run
diff options
context:
space:
mode:
Diffstat (limited to 'insel-run')
-rw-r--r--insel-run48
1 files changed, 48 insertions, 0 deletions
diff --git a/insel-run b/insel-run
new file mode 100644
index 0000000..b4c0b88
--- /dev/null
+++ b/insel-run
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+INSEL=$(command -v insel)
+if [ -z "$INSEL" ]; then
+ echo "Error: insel not found in PATH" >&2
+ exit 1
+fi
+
+if [ -t 1 ]; then
+ exec "$INSEL" "$@"
+fi
+
+run_in_term() {
+ term="$1"
+ shift
+ if ! command -v "$term" >/dev/null 2>&1; then
+ return 1
+ fi
+ export TERM
+ case "$term" in
+ kitty)
+ "$term" -- "$INSEL" "$@"
+ ;;
+ alacritty|wezterm|st)
+ "$term" -e "$INSEL" "$@"
+ ;;
+ *)
+ "$term" -e sh -c "exec $INSEL" "$@"
+ ;;
+ esac
+ [ $? -eq 0 ] && exit 0
+}
+
+run_in_term kitty "$@"
+run_in_term alacritty "$@"
+run_in_term wezterm "$@"
+run_in_term gnome-terminal "$@"
+run_in_term konsole "$@"
+run_in_term xfce4-terminal "$@"
+run_in_term lxterminal "$@"
+run_in_term mate-terminal "$@"
+run_in_term terminator "$@"
+run_in_term tilix "$@"
+run_in_term xterm "$@"
+run_in_term st "$@"
+
+echo "Error: No terminal emulator found" >&2
+exit 1