--- /dev/null
+#!/bin/bash
+
+##################################################################
+# START_IP_HEADER #
+# #
+# Written by Francois Fleuret #
+# Contact <francois.fleuret@idiap.ch> for comments & bug reports #
+# #
+# END_IP_HEADER #
+##################################################################
+
+# You can add in your ~/.inputrc something like
+# Control-h: "smarthist.sh\n"
+# so that C-h will invoke this script
+
+EXE=./selector
+
+# We do not want a security breach
+
+OUT=/tmp/selector.out
+touch ${OUT}
+chmod go-rwx ${OUT}
+
+${EXE} ~/.bash_history
+
+# We set the echo off
+
+OLD_SETTINGS=`stty -g`
+stty -echo raw
+
+# Put the line we got into the tty buffer
+
+writevt `tty` "`cat ${OUT}`"
+
+# Set back the echo as it was
+
+stty ${OLD_SETTINGS}
+
+# Remove the file containing what we got from the selector
+
+\rm ${OUT}