From afc33e0e043f28bc1678c27e875c4c84ffef83bd Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 28 Sep 2024 21:10:11 +0200 Subject: Add translate-prompt script --- local/bin/translate-prompt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 local/bin/translate-prompt (limited to 'local/bin') diff --git a/local/bin/translate-prompt b/local/bin/translate-prompt new file mode 100755 index 0000000..9419f2a --- /dev/null +++ b/local/bin/translate-prompt @@ -0,0 +1,40 @@ +#!/bin/sh + +command -v trans > /dev/null || + { echo "translate-shell not installed" ; exit 1 ; } +command -v rofi > /dev/null && + menu_exec='rofi -dmenu' || + menu_exec='dmenu' + +choice="$( +$menu_exec < "$text_file" + ;; + 'Open Editor') + text_file="$(mktemp /tmp/translate_prompt_text_XXXXXX)" + "$TERMINAL" -e "$EDITOR" "$text_file" + ;; + *) + echo -n "$choice" > "$text_file" + ;; +esac + +brief=-brief +if [ "$(head -c1 "$text_file")" = '#' ] +then + brief='' + sed -i '1 s/^#//' "$text_file" +fi + +"$TERMINAL" -e trans $brief -view -input "$text_file" -- cgit