(no title)
iwalton3 | 3 years ago
tabChar=$'\t'
function prompt_command {
echo "$(date +%Y-%m-%d--%H-%M-%S)$tabChar$(hostname)$tabChar$PWD$tabChar$(history 1)" >> ~/.full_history
}
export PROMPT_COMMAND=prompt_command
function c {
while read -r _ dir
do
if [[ -e "$dir" ]]
then
echo "$dir"
cd "$dir"
break
fi
done < <(cat ~/.full_history | tail -n 10000 \
| cut -f 3 | sort | uniq -dc | sort -hr | grep "/$1$")
}
function _c {
local IFS=$'\n'
COMPREPLY=( $(cat ~/.full_history | tail -n 10000 \
| cut -f 3 | sort | uniq -dc | sort -hr \
| sed 's/.*\///g' | grep "^$2") )
}
complete -F _c c
revscat|3 years ago
kuratkull|3 years ago