Compare commits
30 Commits
Author | SHA1 | Date |
---|---|---|
Bruno Sutic | 25cb91f42d | |
Julian Antonielli | e463ee9a75 | |
Bruno Sutic | 5d089e418e | |
Bruno Sutic | 8e8043c439 | |
Carlos Marx | eba4cbe76f | |
Bruno Sutic | 989d09249e | |
Bruno Sutic | 44af8d8eff | |
Georges Martin | 57d999b7df | |
Bruno Sutic | 0dd7aed9a0 | |
Bruno Sutic | e91b178ff8 | |
timss | bb9a833510 | |
Evan Niessen-Derry | df09a123ef | |
Evan Niessen-Derry | 6bd0e2b221 | |
Bruno Sutic | 526110eb9b | |
Bruno Sutic | b0a8527eb4 | |
Bruno Sutic | 3baff4e795 | |
Bruno Sutic | 4055083386 | |
Bruno Sutic | cd7faa8bba | |
Bruno Sutic | 9a4309ed63 | |
Bruno Sutic | 2fe5834f30 | |
Bruno Sutic | 2ce7679f9d | |
Bruno Sutic | e1aabe4b8a | |
Bruno Sutic | fff9a53723 | |
Bruno Sutic | 2476f3fb23 | |
Bruno Sutic | 3ea5b9f6b9 | |
Bruno Sutic | 9d61936c53 | |
Bruno Sutic | e725d88256 | |
Bruno Sutic | ba0b52d999 | |
Bruno Sutic | b5a1c2ade5 | |
Bruno Sutic | 22d1305cb7 |
|
@ -0,0 +1,2 @@
|
|||
# Force text files to have unix eols, so Windows/Cygwin does not break them
|
||||
*.* eol=lf
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -1,6 +1,22 @@
|
|||
# Changelog
|
||||
|
||||
### master
|
||||
- remove `detach-on-destroy`
|
||||
- do not set `aggressive-resize` on iTerm terminal
|
||||
- disable `detach-on-destroy`
|
||||
|
||||
### v3.0.0, 2015-06-24
|
||||
- remove 'almost sensible' feature
|
||||
|
||||
### v2.3.0, 2015-06-24
|
||||
- update to support \*THE\* latest tmux version
|
||||
- bugfix for `prefix + R` key binding
|
||||
- fix for tmux 2.0 `default-terminal` option (thanks @kwbr)
|
||||
|
||||
### v2.2.0, 2015-02-10
|
||||
- bugfix in `key_binding_not_set`: the regex is now properly detecting key
|
||||
bindings with `-r` flag.
|
||||
- enable `aggressive-resize`
|
||||
|
||||
### v2.1.0, 2014-12-12
|
||||
- check before binding `prefix + prefix` (@m1foley)
|
||||
|
|
106
README.md
106
README.md
|
@ -4,6 +4,8 @@ A set of tmux options that should be acceptable to everyone.
|
|||
|
||||
Inspired by [vim-sensible](https://github.com/tpope/vim-sensible).
|
||||
|
||||
Tested and working on Linux, OSX and Cygwin.
|
||||
|
||||
### Principles
|
||||
|
||||
- `tmux-sensible` options should be acceptable to **every** tmux user!<br/>
|
||||
|
@ -22,89 +24,74 @@ Inspired by [vim-sensible](https://github.com/tpope/vim-sensible).
|
|||
|
||||
### Options
|
||||
|
||||
# utf8 is on
|
||||
set -g utf8 on
|
||||
set -g status-utf8 on
|
||||
```tmux
|
||||
# Address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
set -s escape-time 0
|
||||
|
||||
# address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
set -s escape-time 0
|
||||
# Increase scrollback buffer size from 2000 to 50000 lines
|
||||
set -g history-limit 50000
|
||||
|
||||
# increase scrollback buffer size
|
||||
set -g history-limit 50000
|
||||
# Increase tmux messages display duration from 750ms to 4s
|
||||
set -g display-time 4000
|
||||
|
||||
# tmux messages are displayed for 4 seconds
|
||||
set -g display-time 4000
|
||||
# Refresh 'status-left' and 'status-right' more often, from every 15s to 5s
|
||||
set -g status-interval 5
|
||||
|
||||
# refresh 'status-left' and 'status-right' more often
|
||||
set -g status-interval 5
|
||||
# (OS X) Fix pbcopy/pbpaste for old tmux versions (pre 2.6)
|
||||
set -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||
|
||||
# set only on OS X where it's required
|
||||
set -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||
# Upgrade $TERM
|
||||
set -g default-terminal "screen-256color"
|
||||
|
||||
# upgrade $TERM
|
||||
set -g default-terminal "screen-256color"
|
||||
# Emacs key bindings in tmux command prompt (prefix + :) are better than
|
||||
# vi keys, even for vim users
|
||||
set -g status-keys emacs
|
||||
|
||||
# emacs key bindings in tmux command prompt (prefix + :) are better than
|
||||
# vi keys, even for vim users
|
||||
set -g status-keys emacs
|
||||
# Focus events enabled for terminals that support them
|
||||
set -g focus-events on
|
||||
|
||||
# focus events enabled for terminals that support them
|
||||
set -g focus-events on
|
||||
# Super useful when using "grouped sessions" and multi-monitor setup
|
||||
setw -g aggressive-resize on
|
||||
```
|
||||
|
||||
### Key bindings
|
||||
|
||||
# easier and faster switching between next/prev window
|
||||
bind C-p previous-window
|
||||
bind C-n next-window
|
||||
```tmux
|
||||
# Easier and faster switching between next/prev window
|
||||
bind C-p previous-window
|
||||
bind C-n next-window
|
||||
```
|
||||
|
||||
Above bindings enhance the default `prefix + p` and `prefix + n` bindings by
|
||||
allowing you to hold `Ctrl` and repeat `a + p`/`a + n` (if your prefix is
|
||||
`C-a`), which is a lot quicker.
|
||||
|
||||
# source .tmux.conf as suggested in `man tmux`
|
||||
bind R source-file '~/.tmux.conf'
|
||||
```tmux
|
||||
# Source .tmux.conf as suggested in `man tmux`
|
||||
bind R source-file '~/.tmux.conf'
|
||||
```
|
||||
|
||||
"Adaptable" key bindings that build upon your `prefix` value:
|
||||
|
||||
# if prefix is 'C-a'
|
||||
bind C-a send-prefix
|
||||
bind a last-window
|
||||
```tmux
|
||||
# If prefix is 'C-a'
|
||||
bind C-a send-prefix
|
||||
bind a last-window
|
||||
```
|
||||
|
||||
If prefix is `C-b`, above keys will be `C-b` and `b`.<br/>
|
||||
If prefix is `C-z`, above keys will be `C-z` and `z`... you get the idea.
|
||||
|
||||
### Almost sensible options - deprecated
|
||||
|
||||
**Note**: this feature is deprecated and will be removed from `tmux-sensible`
|
||||
in the next major release. The reason for this is to focus this plugin on doing
|
||||
just one thing (and hopefully doing it well).<br/>
|
||||
If you were using 'almost sensible' the path forward is to move all the
|
||||
below options to your `.tmux.conf`.
|
||||
|
||||
Activate these by putting `set -g @almost-sensible 'on'` in `.tmux.conf`.
|
||||
|
||||
# C-a should be the Tmux default prefix, really
|
||||
set -g prefix C-a
|
||||
set -g mode-keys vi
|
||||
|
||||
# enable mouse features for terminals that support it
|
||||
set -g mouse-resize-pane on
|
||||
set -g mouse-select-pane on
|
||||
set -g mouse-select-window on
|
||||
|
||||
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
|
||||
|
||||
Add plugin to the list of TPM plugins in `.tmux.conf`:
|
||||
|
||||
set -g @tpm_plugins ' \
|
||||
tmux-plugins/tpm \
|
||||
tmux-plugins/tmux-sensible \
|
||||
'
|
||||
```tmux
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
```
|
||||
|
||||
Hit `prefix + I` to fetch the plugin and source it. That's it!
|
||||
|
||||
You might also want to restart your tmux server, just in case.
|
||||
|
||||
### Manual Installation
|
||||
|
||||
Clone the repo:
|
||||
|
@ -113,14 +100,11 @@ Clone the repo:
|
|||
|
||||
Add this line to the bottom of `.tmux.conf`:
|
||||
|
||||
run-shell ~/clone/path/sensible.tmux
|
||||
```tmux
|
||||
run-shell ~/clone/path/sensible.tmux
|
||||
```
|
||||
|
||||
Reload TMUX environment:
|
||||
|
||||
# type this in terminal
|
||||
$ tmux source-file ~/.tmux.conf
|
||||
|
||||
You might also want to restart your tmux server, just in case.
|
||||
Reload TMUX environment with `$ tmux source-file ~/.tmux.conf`, and that's it.
|
||||
|
||||
### Other goodies
|
||||
|
||||
|
@ -130,6 +114,8 @@ You might also find these useful:
|
|||
improve tmux search and reduce mouse usage
|
||||
- [pain control](https://github.com/tmux-plugins/tmux-pain-control)
|
||||
useful standard bindings for controlling panes
|
||||
- [resurrect](https://github.com/tmux-plugins/tmux-resurrect)
|
||||
persists tmux environment across system restarts
|
||||
|
||||
### License
|
||||
|
||||
|
|
|
@ -2,13 +2,18 @@
|
|||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
ALMOST_SENSIBLE_OPTION="@almost-sensible"
|
||||
# used to match output from `tmux list-keys`
|
||||
KEY_BINDING_REGEX="bind-key[[:space:]]\+\(-r[[:space:]]\+\)\?\(-T prefix[[:space:]]\+\)\?"
|
||||
|
||||
is_osx() {
|
||||
local platform=$(uname)
|
||||
[ "$platform" == "Darwin" ]
|
||||
}
|
||||
|
||||
iterm_terminal() {
|
||||
[[ "${TERM_PROGRAM}" =~ ^iTerm || "${LC_TERMINAL}" =~ ^iTerm ]]
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
local command="$1"
|
||||
type "$command" >/dev/null 2>&1
|
||||
|
@ -40,8 +45,8 @@ server_option_value_not_changed() {
|
|||
}
|
||||
|
||||
key_binding_not_set() {
|
||||
local key="$1"
|
||||
if $(tmux list-keys | grep -q "bind-key[[:space:]]\+${key}"); then
|
||||
local key="${1//\\/\\\\}"
|
||||
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]"); then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
|
@ -51,7 +56,7 @@ key_binding_not_set() {
|
|||
key_binding_not_changed() {
|
||||
local key="$1"
|
||||
local default_value="$2"
|
||||
if $(tmux list-keys | grep -q "bind-key[[:space:]]\+${key}[[:space:]]\+${default_value}"); then
|
||||
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]\+${default_value}"); then
|
||||
# key still has the default binding
|
||||
return 0
|
||||
else
|
||||
|
@ -59,20 +64,20 @@ key_binding_not_changed() {
|
|||
fi
|
||||
}
|
||||
|
||||
# "almost sensible" is deprecated
|
||||
almost_sensible_on() {
|
||||
[ "$(tmux show-option -gvq "$ALMOST_SENSIBLE_OPTION")" == "on" ]
|
||||
get_tmux_config() {
|
||||
local tmux_config_xdg="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
|
||||
local tmux_config="$HOME/.tmux.conf"
|
||||
|
||||
if [ -f "${tmux_config_xdg}" ]; then
|
||||
echo "${tmux_config_xdg}"
|
||||
else
|
||||
echo ${tmux_config}
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
# OPTIONS
|
||||
|
||||
# enable utf8
|
||||
tmux set-option -g utf8 on
|
||||
|
||||
# enable utf8 in tmux status-left and status-right
|
||||
tmux set-option -g status-utf8 on
|
||||
|
||||
# address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
if server_option_value_not_changed "escape-time" "500"; then
|
||||
tmux set-option -s escape-time 0
|
||||
|
@ -98,10 +103,14 @@ main() {
|
|||
tmux set-option -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||
fi
|
||||
|
||||
# upgrade $TERM
|
||||
# upgrade $TERM, tmux 1.9
|
||||
if option_value_not_changed "default-terminal" "screen"; then
|
||||
tmux set-option -g default-terminal "screen-256color"
|
||||
fi
|
||||
# upgrade $TERM, tmux 2.0+
|
||||
if server_option_value_not_changed "default-terminal" "screen"; then
|
||||
tmux set-option -s default-terminal "screen-256color"
|
||||
fi
|
||||
|
||||
# emacs key bindings in tmux command prompt (prefix + :) are better than
|
||||
# vi keys, even for vim users
|
||||
|
@ -110,17 +119,9 @@ main() {
|
|||
# focus events enabled for terminals that support them
|
||||
tmux set-option -g focus-events on
|
||||
|
||||
# ALMOST SENSIBLE OPTIONS - DEPRECATED
|
||||
|
||||
if almost_sensible_on; then
|
||||
# C-a should be the Tmux default prefix, really
|
||||
tmux set-option -g prefix C-a
|
||||
tmux set-option -g mode-keys vi
|
||||
|
||||
# enable mouse features for terminals that support it
|
||||
tmux set-option -g mouse-resize-pane on
|
||||
tmux set-option -g mouse-select-pane on
|
||||
tmux set-option -g mouse-select-window on
|
||||
# super useful when using "grouped sessions" and multi-monitor setup
|
||||
if ! iterm_terminal; then
|
||||
tmux set-window-option -g aggressive-resize on
|
||||
fi
|
||||
|
||||
# DEFAULT KEY BINDINGS
|
||||
|
@ -130,7 +131,7 @@ main() {
|
|||
|
||||
# if C-b is not prefix
|
||||
if [ $prefix != "C-b" ]; then
|
||||
# unbind obsolte default binding
|
||||
# unbind obsolete default binding
|
||||
if key_binding_not_changed "C-b" "send-prefix"; then
|
||||
tmux unbind-key C-b
|
||||
fi
|
||||
|
@ -157,9 +158,11 @@ main() {
|
|||
|
||||
# source `.tmux.conf` file - as suggested in `man tmux`
|
||||
if key_binding_not_set "R"; then
|
||||
tmux bind-key R run-shell -b ' \
|
||||
tmux source-file ~/.tmux.conf > /dev/null; \
|
||||
tmux display-message "Sourced .tmux.conf!"'
|
||||
local tmux_config=$(get_tmux_config)
|
||||
|
||||
tmux bind-key R run-shell " \
|
||||
tmux source-file ${tmux_config} > /dev/null; \
|
||||
tmux display-message 'Sourced ${tmux_config}!'"
|
||||
fi
|
||||
}
|
||||
main
|
||||
|
|
Loading…
Reference in New Issue