diff --git a/qcd_function b/qcd_function index 9767133..28bcef8 100644 --- a/qcd_function +++ b/qcd_function @@ -13,7 +13,7 @@ function cd_history () { alias cd=cd_history function qcd() { - while getopts alh opt + while getopts alhm opt do case "$opt" in a) # Adding @@ -32,6 +32,21 @@ function qcd() { echo ==Saved ~/.qcd: cat ~/.qcd ;; + m) + IFS=$'\n' + for line in $( cat ~/.bash_cdhistory ); + do if [ -d "${line/*:/}" ]; + then echo "$line" >> ~/.bash_cdhistory.tmp + fi + done + mv ~/.bash_cdhistory.tmp ~/.bash_cdhistory + for line in $( cat ~/.qcd ); + do if [ -d "${line/*:/}" ]; + then echo "$line" >> ~/.qcd.tmp + fi + done + mv ~/.qcd.tmp ~/.qcd + ;; h) echo "qcd [-al] [name]" echo "Change current working path based on the list ~/.qcd" @@ -44,6 +59,9 @@ function qcd() { echo " " echo "qcd -l " echo " Lists the paths" + echo " " + echo "qcd -m " + echo " Maintain the list files, deleting non-existing entries" ;; esac done