Created
May 20, 2013 17:17
-
-
Save handlename/5613691 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 my:chomp (str) | |
(replace-regexp-in-string "[\n\r]+$" "" str)) | |
(defun my:git-project-p () | |
(string= | |
(my:chomp | |
(shell-command-to-string "git rev-parse --is-inside-work-tree")) | |
"true")) | |
(defun my:tmux-do-command-for-file (filepath command) | |
(progn | |
(shell-command | |
(format "tmux new-window 'cd %s; %s -- %s'" | |
(file-name-directory filepath) | |
command | |
(file-name-nondirectory filepath))))) | |
(defun my:tmux-do-command-in-git-project (command) | |
(if (my:git-project-p) | |
(my:tmux-do-command-for-file buffer-file-name command) | |
(progn | |
(message "not in git repository.") | |
nil))) | |
(defun my:open-iterm () | |
(shell-command (format "open -a iTerm"))) | |
(defun my:git-diff-current-file () | |
(interactive) | |
(if (my:tmux-do-command-in-git-project "git diff") | |
(my:open-iterm))) | |
(defun my:tig-blame-current-file () | |
(interactive) | |
(if (my:tmux-do-command-in-git-project "tig blame") | |
(my:open-iterm))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment