Noam Postavsky writes: > There doesn't need to be trailing whitespace between the last "^" and > subsequent text, bash: > So I think this should do it? > > ... > (string-match > "^\\^\\([^^]+\\)\\^\\([^^]+\\)\\(?:\\^\\(.*\\)\\)?$" > line)) > ;; Save trailing match as `eshell-history-reference' runs string-match. > (let ((matched-end (match-string 3 line))) > ... Yup, that regex works perfectly for everything I tried, and preserves the white-space at the end of the target (as bash does). I think it's a good idea to follow bash as closely as possible. For convenience, I've attached a new patch with those changes. Thanks, -Jay