If you spend long periods of you day playing around in the command line, you should be thinking of installing tmux.
what is tmux?
The official definition is:
tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.
The tl;dr is:
tmux lets you open a million terminal windows but without making a mess.
installation ( on a mac )
As long as you have homebrew installed, you can run:
The tmux is looking for the config file
~/.tmux.conf by default.
Interacting with tmux is by an action key followed by a key command. By default the action key for tmux is
ctrl+b. I find that a little unwieldy to type, so I switched it to be
set -g default-terminal "screen-256color"
set-option -g prefix C-a
bind-key C-a last-window
bind R kill-session
bind r source-file ~/.tmux.conf
I find it much easier to interact with anything using the vim-style key bindings. Tmux is no exceptions.
set-window-option -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
bind s split-window -v
bind v split-window -h
set -g base-index 1
setw -g pane-base-index 1
mac clipboard settings
Tmux doesn't play well with the mac osx clipboard. Thoughbot has a pretty awesome blog post on how to get copy and paste working again. Here is a quick summary:
Install the homebrew package
$ brew install reattach-to-user-namespace
and add these bindings to your
.tmux.conf. Now copy is
ctrl-a + ctrl-c
set-option -g default-command "reattach-to-user-namespace -l zsh"
bind C-c run "tmux show-buffer | reattach-to-user-namespace pbcopy"
bind C-v run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
working with the mouse
It's always nice to have the option. Sometimes when I'm combing through log files and I find it a easier to use the mouse. It also makes it easier to pair with people if they aren't framiliar with tmux.
set-window-option -g mode-mouse on
set-option -g mouse-select-pane on
set-option -g mouse-resize-pane on
set-option -g mouse-select-window on
making it pretty
This is the theme I have wasted too many hours tweaking. Feel free to do the same.
set -g status-fg white
set -g status-bg black
setw -g window-status-fg green
setw -g window-status-bg default
setw -g window-status-attr dim
setw -g window-status-current-fg black
setw -g window-status-current-bg magenta
setw -g window-status-current-attr dim
set -g pane-border-fg green
set -g pane-border-bg black
set -g pane-active-border-fg green
set -g pane-active-border-bg white
set -g message-fg white
set -g message-bg black
set -g message-attr bright
set -g status-utf8 on
set -g status-interval 60
set -g status-left-length 40
set -g status-justify centre
set -g status-left "#[fg=green]#(git rev-parse --abbrev-ref HEAD)"