Last active
November 23, 2018 13:04
-
-
Save dfeich/50ee86c3d4338dbc878b to your computer and use it in GitHub Desktop.
Emacs function to open a gnome-terminal at location of default-directory (handles remote locations)
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 dfeich/gnome-terminal (&optional path) | |
"Opens a gnome terminal at PATH. If no PATH is given, it uses | |
the value of `default-directory'. PATH may be a tramp remote path." | |
(interactive) | |
(unless path (setq path default-directory)) | |
(if (tramp-tramp-file-p path) | |
(let ((tstruct (tramp-dissect-file-name path))) | |
(cond | |
((equal (tramp-file-name-method tstruct) "ssh") | |
(call-process "/usr/bin/gnome-terminal" nil nil nil | |
"--" "bash" "-c" | |
(format "ssh -t %s 'cd %s; exec bash'; exec bash" | |
(tramp-file-name-host tstruct) | |
(tramp-file-name-localname tstruct)))) | |
(t (error "not implemented for method%s" | |
(tramp-file-name-method tstruct))))) | |
(call-process "/usr/bin/gnome-terminal" nil nil nil | |
"--" "bash" "-c" | |
(format "cd %s;exec bash" path)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Ubuntu 18.04 with gnome-terminal 3.28.2-1ubuntu1~18 I had to adapt to the fact that the "-x" flag to gnome-terminal is becoming obsolete. Can be replaced by "--" to indicate to gnome-terminal that the following sequence is a command and should not be parsed by gnome-terminal as an option containing string.