Set the maximum size of the history to 1000 lines.
[selector.git] / 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 () {