Inspired by `eev’, I made this. The command below makes it possible to send commands to eshell from another buffer. Bind the some key to this command and you can then easily send the current line for execution in eshell.

(defun my-eshell-execute-current-line ()
  "Insert text of current line in eshell and execute."
  (require 'eshell)
  (let ((command (buffer-substring
    (let ((buf (current-buffer)))
      (unless (get-buffer eshell-buffer-name)
      (display-buffer eshell-buffer-name t)
      (switch-to-buffer-other-window eshell-buffer-name)
      (insert command)
      (switch-to-buffer-other-window buf))))

(global-set-key [f8] 'my-eshell-execute-current-line)

And yes, I know about the history in eshell. But that’s my problem; I always end up losing my eshell history and bash history files and when I need that cool command I used a year ago I can never find it. Hence this hack which allows me to keep all my eshell commands in a simple text file that I keep a controlled backup of.