Last active
August 29, 2015 14:02
-
-
Save tdksk/118fa71539b77e18c02c to your computer and use it in GitHub Desktop.
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 git-top-directory () | |
(file-name-as-directory | |
(replace-regexp-in-string | |
"\n" "" | |
(shell-command-to-string "git rev-parse --show-toplevel")))) | |
(defun open-current-git-top-directory-in-tmux-new-pane () | |
(interactive) | |
(let ((top-dir (git-top-directory))) | |
(unless (file-directory-p top-dir) | |
(setq top-dir "")) | |
(let* ((dir top-dir) | |
(cmd (concat "tmux split-window -v \"cd " dir "; exec $SHELL\""))) | |
(cond ((eq (shell-command cmd) 0) | |
(message "Open directory %s in tmux new pane." dir)) | |
(t | |
(message "Failed to create new pane in tmux.")))))) | |
(global-set-key (kbd "M-t") 'open-current-git-top-directory-in-tmux-new-pane) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment