I am making a bash function that show a menu binded to pgdown to browse through a a window which list my history (like 4dos/4nt etcetera). I have made so one line is always highlighted.
$pos is where in the history I want the list to start
$ function hidown (){ if [ "$down" -gt 1 ]; then ((--down)); else down=100; fi ; hismenu_down "$down"; }
$ bind -x '"\e[6~":"hidowm"'
$ down=100
`
function hismenu_down()
{
pos=$1; hilength=10; hirange="$(($hilength+$pos))";
hisstring=$(history | tail -n $hirange)
for ((i=hilength; i>=0; --i)); do
if [ $i == 6 ]; then tput setaf 7; else tput setaf 6; fi;
tput cup $i 55;
printf "$hisstring" | tail -n "$(($i+$pos))" | head -n1 | cut -c1-105;
done; tput sgr0; tput rc;
}
I would like to have the highlighted text output at command line so I just have to put return or edit the text before I hit return to execute the command.
I will also temporarily bind key esc to remove the code from command line (and possible other actions to delete the code from the history list) and at the same time rebind the same key to afterwards be binded to the its default.
But that part I can clue out for myself. What I am asking for, is only this - how do I put a string to the commandline?