#!/bin/bash
case $LANG in
pl*)
TYPE_TO_SEARCH="pisz, aby wyszukać"
HISTHELPER="Ściągawka z historii"
NOTHING="Niczego tu nie ma... Otwórz terminal (W-t) i wykonaj jakieś polecenie"
;;
es*)
TYPE_TO_SEARCH="Buscar"
HISTHELPER="Historia breve"
NOTHING="Nada que ver aquí...Abrir la terminal (W-t) y ejecutar algunos comandos"
;;
*)
TYPE_TO_SEARCH="Type to filter"
HISTHELPER="History helper"
NOTHING="Nothing to see here... Open terminal (W-t) and run some commands"
;;
esac
MENU_ITEMS=/tmp/history_list.csv
trap "rm -f $MENU_ITEMS" EXIT
if [ -f ~/.bash_history ]; then
echo "@search,,10,5,292,20,4,left,top,auto,#262626,\"\"\" $TYPE_TO_SEARCH\"\"\"" >/tmp/history_list.csv
echo "^sep($HISTHELPER)" >>/tmp/history_list.csv
while read -r line ; do
printf "\"\"\"%s\"\"\",xdotool type --delay 0 \'%s\'\n" "$line" "$line" >> $MENU_ITEMS
done < <(cat ~/.bash_history|sort|uniq)
else
echo "^sep($HISTHELPER)" >/tmp/history_list.csv
echo "\"\"\"$NOTHING\"\"\",exo-open --launch TerminalEmulator" >>/tmp/history_list.csv
fi
### RUN
if [ $1 == "-s" ]; then
. /usr/bin/pipemenu-standalone.cfg
MENU_PADDING_TOP=24
MENU_HALIGN="center"
MENU_VALIGN="top"
MENU_MARGIN_Y=40
jgmenu_icon_size=0
JGWIDTH=500
mkconfigfile
jgmenu --config-file=${CONFIG_FILE} --csv-file=/tmp/history_list.csv 2>/dev/null
rm -f /tmp/history_list.csv
exit 0
fi
#cat ${CONFIG_FILE}
cat ${MENU_ITEMS}