summaryrefslogtreecommitdiff
path: root/init.el
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2014-09-11 15:44:14 +0200
committerrekado <rekado@elephly.net>2014-09-11 15:44:14 +0200
commita5537fc64dd69bc906c0967d374bd96323ea0cdf (patch)
tree418e7e965ffe04d3cd1906152abf416d007b6254 /init.el
parentc55119ef1300d5ff0224a8259cbdd14314ae2b54 (diff)
eshell-mode: add function to print remote home dir path
Diffstat (limited to 'init.el')
-rw-r--r--init.el16
1 files changed, 14 insertions, 2 deletions
diff --git a/init.el b/init.el
index 33a53bb..c2f5b17 100644
--- a/init.el
+++ b/init.el
@@ -305,8 +305,9 @@
(goto-line line))
(find-file (pop args)))))
-;; convenience function to input the remote root when in a directory
-;; on a remote host
+
+;; convenience functions to input the remote root/home dir when in a
+;; directory on a remote host
(defun my/tramp-root ()
"Print root directory on the remote host."
(interactive)
@@ -315,8 +316,19 @@
(concat (car pieces) ":/")
"/"))))
+(defun my/tramp-home ()
+ "Print home directory path on the remote host."
+ (interactive)
+ (let ((pieces (split-string (eshell/pwd) ":/")))
+ (insert-string (if (> (length pieces) 1)
+ (concat (car pieces) ":~/")
+ "~/"))))
+
(add-hook 'eshell-mode-hook
'(lambda () (define-key eshell-mode-map (kbd "C-c /") 'my/tramp-root)))
+(add-hook 'eshell-mode-hook
+ '(lambda () (define-key eshell-mode-map (kbd "C-c ~") 'my/tramp-home)))
+
;; start a hidden eshell on startup