Skip to content

Instantly share code, notes, and snippets.

@kozikow
Created September 12, 2016 20:49
Show Gist options
  • Save kozikow/58b46c45a2c24406dc7cde3f18610433 to your computer and use it in GitHub Desktop.
Save kozikow/58b46c45a2c24406dc7cde3f18610433 to your computer and use it in GitHub Desktop.
My settings for tmux-like tabs
(require 'elscreen)
(require 'helm-elscreen)
(require 'hydra)
(defvar tmux-tabs-mode-map (make-sparse-keymap)
"tmux-tabs-mode's keymap.")
(evil-define-motion tmux-tabs-goto-tab (&optional count)
(if count
(elscreen-goto (- count 1))
(elscreen-next)))
;;;###autoload
(define-minor-mode tmux-tabs-mode
"Integrating Vim-style tabs for Evil mode users."
:global t
:keymap tmux-tabs-mode-map
(elscreen-start))
;;;###autoload
(defun turn-on-tmux-tabs-mode ()
"Enable `tmux-tabs-mode' in the current buffer."
(tmux-tabs-mode 1))
;;;###autoload
(defun turn-off-tmux-tabs-mode ()
"Disable `tmux-tabs-mode' in the current buffer."
(tmux-tabs-mode -1))
(defhydra hydra-tmux-tab (:color blue)
"Do?"
("n" elscreen-next "Next tab")
("p" elscreen-previous "Previous tab")
("c" elscreen-create "Create a new tab")
("x y" elscreen-kill "Kill a tab")
("w" helm-elscreen "Choose a window")
("h" helm-elscreen "Choose a window history")
("1" (elscreen-goto 0))
("2" (elscreen-goto 1))
("3" (elscreen-goto 2))
("4" (elscreen-goto 3))
("5" (elscreen-goto 4))
("6" (elscreen-goto 5))
("7" (elscreen-goto 6))
("8" (elscreen-goto 7))
("9" (elscreen-goto 8))
("q" nil "cancel"))
(define-key tmux-tabs-mode-map (kbd "C-a") 'hydra-tmux-tab/body)
;; (define-key tmux-tabs-mode-map (kbd "C-a n") 'elscreen-next)
;; (define-key tmux-tabs-mode-map (kbd "C-a p") 'elscreen-previous)
;; (define-key tmux-tabs-mode-map (kbd "C-a c") 'elscreen-create)
;; (define-key tmux-tabs-mode-map (kbd "C-a x y") 'elscreen-kill)
;; (define-key tmux-tabs-mode-map (kbd "C-a 1") #'(lambda () (elscreen-goto 0)))
;; (elscreen-goto 1)
;;;###autoload
(define-globalized-minor-mode global-tmux-tabs-mode tmux-tabs-mode turn-on-tmux-tabs-mode)
(provide 'tmux-tabs)
;;; tmux-tabs.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment