+(defun shell-dynamic-complete-filename ()
+ "Dynamically complete the filename at point.
+This completes only if point is at a suitable position for a
+filename argument."
+ (interactive)
+ (let ((opoint (point))
+ (beg (comint-line-beginning-position)))
+ (when (save-excursion
+ (goto-char (if (re-search-backward "[;|&]" beg t)
+ (match-end 0)
+ beg))
+ (re-search-forward "[^ \t][ \t]" opoint t))
+ (comint-dynamic-complete-as-filename))))