Add tmux contrib layer
This commit is contained in:
parent
4725769143
commit
700f19d640
5
contrib/tmux/README.md
Normal file
5
contrib/tmux/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# What is this
|
||||
This is an extension to support evil-tmux-navigator. It requires a little
|
||||
configuration for tmux, so check the upstream documentation.
|
||||
|
||||
[evil-tmux-navigator](https://github.com/Keithbsmiley/evil-tmux-navigator)
|
5
contrib/tmux/extensions.el
Normal file
5
contrib/tmux/extensions.el
Normal file
|
@ -0,0 +1,5 @@
|
|||
(defvar tmux-post-extensions '(tmux))
|
||||
|
||||
(defun tmux/init-tmux ()
|
||||
"Initialize tmux"
|
||||
(use-package tmux))
|
74
contrib/tmux/extensions/tmux/tmux.el
Normal file
74
contrib/tmux/extensions/tmux/tmux.el
Normal file
|
@ -0,0 +1,74 @@
|
|||
;;; tmux.el --- Seamlessly navigate between Emacs and tmux
|
||||
|
||||
;; Author: Keith Smiley <keithbsmiley@gmail.com>
|
||||
;; Created: April 25 2014
|
||||
;; Version: 0.1.5
|
||||
;; Keywords: tmux, evil, vi, vim
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This package is inspired by vim-tmux-navigator.
|
||||
;; It allows you to navigate splits in evil mode
|
||||
;; Along with tmux splits with the same commands
|
||||
;; Include with:
|
||||
;;
|
||||
;; (require 'navigate)
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'evil)
|
||||
|
||||
(defgroup navigate nil
|
||||
"seamlessly navigate between Emacs and tmux"
|
||||
:prefix "navigate-"
|
||||
:group 'evil)
|
||||
|
||||
; Without unsetting C-h this is useless
|
||||
(global-unset-key (kbd "C-h"))
|
||||
|
||||
; This requires windmove commands
|
||||
(when (fboundp 'windmove-default-keybindings)
|
||||
(windmove-default-keybindings))
|
||||
|
||||
(defun tmux-navigate (direction)
|
||||
(let
|
||||
((cmd (concat "windmove-" direction)))
|
||||
(condition-case nil
|
||||
(funcall (read cmd))
|
||||
(error
|
||||
(tmux-command direction)))))
|
||||
|
||||
(defun tmux-command (direction)
|
||||
(shell-command-to-string
|
||||
(concat "tmux select-pane -"
|
||||
(tmux-direction direction))))
|
||||
|
||||
(defun tmux-direction (direction)
|
||||
(upcase
|
||||
(substring direction 0 1)))
|
||||
|
||||
(define-key evil-normal-state-map
|
||||
(kbd "C-h")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(tmux-navigate "left")))
|
||||
(define-key evil-normal-state-map
|
||||
(kbd "C-j")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(tmux-navigate "down")))
|
||||
(define-key evil-normal-state-map
|
||||
(kbd "C-k")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(tmux-navigate "up")))
|
||||
(define-key evil-normal-state-map
|
||||
(kbd "C-l")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(tmux-navigate "right")))
|
||||
|
||||
(provide 'tmux)
|
||||
|
||||
;;; tmux.el ends here
|
Loading…
Reference in a new issue