summaryrefslogtreecommitdiff
path: root/imt
diff options
context:
space:
mode:
authorHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2023-11-25 03:45:16 -0800
committerHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2023-11-25 03:45:16 -0800
commitcb31a5025127f8e16c705c88f439a8f819952827 (patch)
treec84a83e6c50bc9d783e7d6d08d109602bf1a03aa /imt
Moved everything out of dotfiles
Diffstat (limited to 'imt')
-rwxr-xr-ximt55
1 files changed, 55 insertions, 0 deletions
diff --git a/imt b/imt
new file mode 100755
index 0000000..07de6bb
--- /dev/null
+++ b/imt
@@ -0,0 +1,55 @@
+#!/bin/bash
+#Janky ibus table boshiamy implementation for tmux
+
+#gets current window id of IME and puts it here
+code=""
+clear
+while true; do
+ #need IFS="" so read reads spaces
+ OIFS=$IFS
+ export IFS=""; read -rsn1 i
+ export IFS=$OIFS
+ #echo ".$i."
+ if [[ "$i" = [abcdefghijklmnopqrstuvwxyz,.] ]]; then
+ clear
+ #escape periods
+ i=$(echo $i |sed 's/\./\\\./g')
+ code=$code$i
+ opt=$(grep "^$code\s" ~/lang/zh/boshiamy/ibus-boshiamy/boshiamy.txt |\
+ #remove simplfied
+ grep -v 98|\
+ awk '{print $3" "$2}' |\
+ sort -nr|\
+ awk '{print $2}')
+ echo $opt
+ echo $code
+ elif [[ "$i" = [0123456789] ]]; then
+ if [ "$code" == "" ]; then
+ char=$i
+ else
+ clear
+ char=$(echo $opt | awk "{print \$$i}")
+ code=""
+ fi
+ tmux send-key -t "!" "$char"
+ #dirty hack for detecting space
+ elif [ "<$i>" == "< >" ]; then
+ if [ "$code" == "" ]; then
+ char=" "
+ else
+ clear
+ char=$(echo $opt | awk "{print \$1}")
+ code=""
+ fi
+ tmux send-key -t "!" "$char"
+ elif [[ "$i" = '`' ]]; then
+ clear
+ code=""
+ #if enter is pressed then I am done editing
+ elif [[ "$i" = "" ]]; then
+ #-r "!" means the previous window
+ tmux send-keys -t "!" Enter
+ else
+ tmux send-key -t "!" "$i"
+ fi
+done