-function selector-history () {
- ARGS="-c 7 4 0 3 -q -b -i -d -v -w -l 15000"
- FILES=""
-
- # I may have a "local bash history" specific to the current
- # directory, and I also maintain a global "kept command" file. I
- # take all this into account here.
-
- if [[ ${LOCAL_HISTORY_FILE} ]] && [[ -f ${LOCAL_HISTORY_FILE} ]]; then
- FILES="${FILES} ${LOCAL_HISTORY_FILE}"
- fi
-
- if [[ ${KEPT_COMMANDS} ]] && [[ -f ${KEPT_COMMANDS} ]]; then
- selector ${ARGS} ${FILES} <(sed < ${KEPT_COMMANDS} -e 's/^.*: /0 /') <(history)
- else
- selector ${ARGS} ${FILES} <(history)
- fi
-
-}
-
-# M-r puts the selected history line in place of the current one
-
-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"'
-
-# Finds path in the history and make a list of the existing ones
-
-function selector-cd () {
- LIST_TEMP=$(mktemp /tmp/cdlist.XXXXXX)
- for d in $(history | \
- grep ^" *[0-9]* *cd" | \
- awk '{ print $3 }' | \
- grep -v "\.\." | \
- uniq); do
- if [[ -d $d ]]; then
- echo "$d!cd $d"
- fi
- done >> ${LIST_TEMP}
- selector -v -x '!' -d -i ${LIST_TEMP}
- \rm ${LIST_TEMP}
-}
-
-alias c=selector-cd
-
-bind '"\C-[c":"\C-a\C-kselector-cd\C-m"'