[from now] 2013/06/06 11:48:24

diff --git a/.zsh/z.sh b/.zsh/z.sh
index 555b3b6..883ed3d 100755
--- a/.zsh/z.sh
+++ b/.zsh/z.sh
@@ -22,10 +22,9 @@
 #   * z -l foo  # list matches instead of cd
 #   * z -c foo  # restrict matches to subdirs of $PWD

-case $- in
- *i*) ;;
-   *) echo 'ERROR: z.sh is meant to be sourced, not directly executed.'
-esac
+[ -d "${_Z_DATA:-$HOME/.z}" ] && {
+    echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory."
+}

 _z() {

@@ -76,7 +75,7 @@ _z() {
   if [ $? -ne 0 -a -f "$datafile" ]; then
    env rm -f "$tempfile"
   else
-   env mv -f "$tempfile" "$datafile"
+   env mv -f "$tempfile" "$datafile" || env rm -f "$tmpfile"
   fi

  # tab completion
@@ -104,7 +103,8 @@ _z() {
    --) while [ "$1" ]; do shift; local fnd="$fnd $1";done;;
    -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
         c) local fnd="^$PWD $fnd";;
-        h) echo "${_Z_CMD:-z} [-chlrt] args" >&2; return;;
+        h) echo "${_Z_CMD:-z} [-chlrtx] args" >&2; return;;
+        x) sed -i "\:^${PWD}|.*:d" "$datafile";;
         l) local list=1;;
         r) local typ="rank";;
         t) local typ="recent";;