Set the maximum size of the history to 1000 lines.
authorFrancois Fleuret <francois@fleuret.org>
Tue, 25 Oct 2011 06:37:19 +0000 (08:37 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Tue, 25 Oct 2011 06:37:19 +0000 (08:37 +0200)
bash-selector.sh

index abf4059..64cda91 100755 (executable)
@@ -17,8 +17,6 @@
 # Contact <francois.fleuret@idiap.ch> for comments & bug reports        #
 #########################################################################
 
-set -e
-
 # Selector based history
 
 function selector-history () {
@@ -38,7 +36,11 @@ function selector-cd () {
     else
         cd "$@"
     fi
-    echo $PWD | sed -e "s!${HOME}!~!" >> ${SELECTOR_CD_HISTORY}
+    TMP=$(mktemp /tmp/selector-cd.XXXXXX)
+    tail -1000 < ${SELECTOR_CD_HISTORY} > ${TMP}
+    echo $PWD | sed -e "s!${HOME}!~!" >> ${TMP}
+    cat ${TMP} > ${SELECTOR_CD_HISTORY}
+    rm -f ${TMP}
 }
 
 function selector-cd-search () {