+bind '"\C-[r":"\C-a\C-kselector-history\C-m"'
+
+# M-t appends the selected history line and the end of the current one
+
+bind '"\C-[t":"\C-a\C-kselector-history\C-m\C-a\C-y\C-e"'
+
+######################################################################
+# Maintain a list of visited directories and provide a selector-based
+# command to go back to any of them.
+
+export SELECTOR_CD_HISTORY
+
+[[ "${SELECTOR_CD_HISTORY}" ]] || \
+ SELECTOR_CD_HISTORY=${HOME}/.selector-cd-history
+
+function selector-cd-search () {
+ PATH_TEMP=$(mktemp /tmp/selector-cd-path.XXXXXX)
+ selector -t "cd" -l 10000 -d -i -o ${PATH_TEMP} -q ${SELECTOR_CD_HISTORY}
+ cd "$(cat ${PATH_TEMP} | sed -e 's!~!'${HOME}'!')"
+ \rm ${PATH_TEMP}
+}