Created
May 31, 2011 02:51
-
-
Save kriyative/999793 to your computer and use it in GitHub Desktop.
Emacs Lisp function `tail-f`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun tail-f (file) | |
"Create a COMINT mode buffer running the `tail -f` command on | |
specified FILE. If FILE is a ssh/scp style remote file spec, | |
e.g., | |
[email protected]:/path/to/file.txt | |
then a ssh connection is opened to remote.host.com, and `tail -f` | |
is invoked on the remote server." | |
(interactive "fFile: ") | |
(let ((buf-name (concat "tail-f " file)) | |
(re "\\(\\w+\\)@\\([^:]+\\):\\(.*\\)")) | |
(if (string-match re file) | |
(let ((user (match-string 1 file)) | |
(host (match-string 2 file)) | |
(file1 (match-string 3 file))) | |
(make-comint buf-name "ssh" nil | |
"-l" user | |
host | |
"tail" "-f" file1)) | |
(make-comint buf-name "tail" nil "-f" (expand-file-name file))) | |
(pop-to-buffer (concat "*" buf-name "*")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment