Fixed the substitution of HOME.
authorFrancois Fleuret <francois@fleuret.org>
Fri, 11 Nov 2011 21:45:59 +0000 (22:45 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Fri, 11 Nov 2011 21:45:59 +0000 (22:45 +0100)
bash-selector.sh

index 653afc1..3a478f6 100755 (executable)
@@ -54,7 +54,7 @@ function selector-cd () {
     fi
     TMP=$(mktemp /tmp/selector-cd.XXXXXX)
     tail -1000 < ${SELECTOR_CD_HISTORY} > ${TMP}
-    echo $PWD | sed -e "s!${HOME}!~!" >> ${TMP}
+    echo $PWD | sed -e "s!^${HOME}!~!" >> ${TMP}
     cat ${TMP} > ${SELECTOR_CD_HISTORY}
     rm -f ${TMP}
 }
@@ -64,7 +64,7 @@ function selector-cd-search () {
     selector -u -t "cd" -l 10000 -d -i -c 7,2,0,3 -o ${PATH_TEMP} -q ${SELECTOR_CD_HISTORY}
     NEW_PATH="$(cat ${PATH_TEMP} | sed -e 's!~!'${HOME}'!')"
     if [[ -s "${NEW_PATH}" ]]; then
-        selector-cd "$(cat ${PATH_TEMP} | sed -e 's!~!'${HOME}'!')"
+        selector-cd "$(cat ${PATH_TEMP} | sed -e 's!^~!'${HOME}'!')"
     fi
     \rm ${PATH_TEMP}
 }