From 00b36ff401df15e45cabb82b7fca0e3da92f4642 Mon Sep 17 00:00:00 2001 From: q Date: Mon, 7 Jan 2013 12:57:44 +0200 Subject: [PATCH] added maintennance option --- qcd_function | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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