hcd or historycd to jump to previous visited folders
This commit is contained in:
15
qcd_function
15
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
|
||||
|
||||
Reference in New Issue
Block a user