diff --git a/qcd_function b/qcd_function index d4180b5..8458481 100644 --- a/qcd_function +++ b/qcd_function @@ -15,11 +15,26 @@ function cd_history () { } alias cd=cd_history +function hcd() { + local d + + if [ -z "$1" ] + then tail -n 20 "$HOME/.bash_cdhistory" | head -n 19 | cut -d: -f2 | tac | cat -n | sed 's,^ \+,,' | tac + return + fi + d=$( tail -n 20 "$HOME/.bash_cdhistory" | head -n 19 | cut -d: -f2 | tac | cat -n | sed 's,^ \+,,' | grep -h "^$1 " ) + d=${d/* /} + if [ ! -z "$d" ] + then \cd "$d" + fi +} + function qcd() { local OPTIND local OPTARG local opt local case + local d while getopts ae:hiILl:m opt do case "$opt" in