From 4acaee44f90c2564464864a4df19b79cb1d4c5da Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Mon, 10 Feb 2014 09:30:47 +0200 Subject: [PATCH] QCD -e to store match in variable --- qcd_function | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qcd_function b/qcd_function index f11cde3..165bb0c 100644 --- a/qcd_function +++ b/qcd_function @@ -21,7 +21,7 @@ function qcd() { local opt local case - while getopts aiILl:hm opt + while getopts ae:hiILl:m opt do case "$opt" in a) # Adding @@ -73,6 +73,13 @@ complete -F _qcd qcd echo $d return ;; + e) + local d=$( grep $case -h ^"$OPTARG" ~/.qcd <( tac ~/.bash_cdhistory ) | head -n 1 ) + d="${d/*:/}" + echo QCD=$d + QCD="$d" + return + ;; m) local IFS=$'\n' for line in $( cat ~/.bash_cdhistory ); @@ -97,6 +104,7 @@ Keeps a history of folders visited in ~/.bash_cdhistory -a [name] Adds the path to the list You may add the name of the path, but when omitted the basename will be used + -e [name] Show the match, store in variable QCD -i Case insensitive search, must come first. -I Install, with autocompletion (use only once) -l [name] Show the match, but do not change