function __z_add -d "Add PATH to .z file"
  set -l path (command dirname (status -f))

  for i in $Z_EXCLUDE
    if contains -- $PWD $i
      return 0 #Path excluded
    end
  end

  set -l tmpfile (mktemp $Z_DATA.XXXXXX)

  if test -f $tmpfile
    command awk -v path="$PWD" -v now=(date +%s) -F "|" -f $path/zadd.awk $Z_DATA ^ /dev/null > $tmpfile
    cat $tmpfile > $Z_DATA
    rm $tmpfile
  end

  __z_complete
end

function __z_add -d "Add PATH to .z file"
  set -l path (command dirname (status -f))

  for i in $Z_EXCLUDE
    if contains -- $PWD $i
      return 0 #Path excluded
    end
  end

  set -l tmpfile (mktemp $Z_DATA.XXXXXX)

  if test -f $tmpfile
    command awk -v path="$PWD" -v now=(date +%s) -F "|" -f $path/zadd.awk $Z_DATA ^ /dev/null > $tmpfile
    cat $tmpfile > $Z_DATA
    command rm $tmpfile
  end

  __z_complete
end

Use base `rm` for removing tempfile
Use base `rm` for removing tempfile
fisherman/z