Skip to content

Instantly share code, notes, and snippets.

@tdksk
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdksk/118fa71539b77e18c02c to your computer and use it in GitHub Desktop.
Save tdksk/118fa71539b77e18c02c to your computer and use it in GitHub Desktop.
(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