hcd or historycd to jump to previous visited folders

This commit is contained in:
q
2015-01-15 20:51:02 +02:00
parent 11076a5626
commit 8954f87cd0

View File

@@ -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