16 Commits

Author SHA1 Message Date
2ce7679f9d v3.0.0 2015-06-24 16:20:17 +02:00
e1aabe4b8a Remove 'almost sensible' feature 2015-06-24 16:17:49 +02:00
fff9a53723 v2.3.0 2015-06-24 16:12:36 +02:00
2476f3fb23 Fix option for tmux 2.0+ 2015-06-24 15:02:14 +02:00
3ea5b9f6b9 Support *the* latest tmux version 2015-05-08 22:33:06 +02:00
9d61936c53 Bugfix for 'prefix + R' key binding 2015-02-12 16:42:33 +01:00
e725d88256 v2.2.0 2015-02-10 02:13:56 +01:00
ba0b52d999 Enable 2015-02-10 02:13:14 +01:00
b5a1c2ade5 Fix regex in key_binding_not_set
Fixes #15
2014-12-23 23:04:28 +01:00
22d1305cb7 Add a link to tmux-resurrect to the readme 2014-12-12 23:42:14 +01:00
c20bc5c4e2 v2.1.0 2014-12-12 23:25:39 +01:00
294e607f83 Deprecate "almost sensible" feature 2014-12-12 23:17:34 +01:00
d2565e5f10 Enable focus-events 2014-12-12 22:40:09 +01:00
babfd71d08 Update changelog and readme 2014-12-03 13:22:19 +01:00
c95eb0d88d Merge pull request #13 from m1foley/safe_bind_prefix
Don't overwrite $prefix if already bound
2014-12-03 13:19:50 +01:00
df5b537d21 Don't overwrite $prefix if already bound 2014-12-02 17:55:10 -08:00
3 changed files with 54 additions and 54 deletions

View File

@ -2,6 +2,25 @@
### master
### 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)
- enable `focus-events`
- deprecate 'almost sensible' feature. The reason for this is to focus the
plugin on doing just one thing.
### v2.0.0, 2014-10-03
- bugfix: prevent exiting tmux if 'reattach-to-user-namespace' is not installed
- remove all mouse-related options

View File

@ -1,31 +1,26 @@
# Tmux sensible
A set of tmux options that should be acceptable for everyone.
A set of tmux options that should be acceptable to everyone.
Inspired by [vim-sensible](https://github.com/tpope/vim-sensible).
### Core principles
### Principles
- core `tmux-sensible` options should be acceptable to **every** tmux user!<br/>
If any option bothers you, please open an issue and it will probably be
updated (or removed).
- `tmux-sensible` options should be acceptable to **every** tmux user!<br/>
If any of the options bothers you, please open an issue and it will probably
be updated (or removed).
- if you think a new option should be added, feel free to open a pull request.
- **no overriding** of user defined settings.<br/>
Your existing `.tmux.conf` settings are respected and they won't be changed.
That way you can use `tmux-sensible` if you have a few specific options.
### Almost sensible principles
- widely used settings that do not make it into the 'core'
- explicitly enabled with `set -g @almost-sensible 'on'`
### Goals
- group standard tmux community options in one place
- remove clutter from your `.tmux.conf`
- educate new tmux users about basic options
### Core options
### Options
# utf8 is on
set -g utf8 on
@ -53,7 +48,13 @@ Inspired by [vim-sensible](https://github.com/tpope/vim-sensible).
# vi keys, even for vim users
set -g status-keys emacs
### Core key bindings
# 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
@ -75,27 +76,14 @@ allowing you to hold `Ctrl` and repeat `a + p`/`a + n` (if your prefix is
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
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 " \
set -g @tpm_plugins ' \
tmux-plugins/tpm \
tmux-plugins/tmux-sensible \
"
'
Hit `prefix + I` to fetch the plugin and source it. That's it!
@ -111,12 +99,7 @@ Add this line to the bottom of `.tmux.conf`:
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
@ -126,6 +109,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

View File

@ -2,7 +2,8 @@
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)
@ -41,7 +42,7 @@ server_option_value_not_changed() {
key_binding_not_set() {
local key="$1"
if $(tmux list-keys | grep -q "bind-key[[:space:]]\+${key}"); then
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]"); then
return 1
else
return 0
@ -51,7 +52,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,10 +60,6 @@ key_binding_not_changed() {
fi
}
almost_sensible_on() {
[ "$(tmux show-option -gvq "$ALMOST_SENSIBLE_OPTION")" == "on" ]
}
main() {
# OPTIONS
@ -97,27 +94,24 @@ 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
tmux set-option -g status-keys emacs
# ALMOST SENSIBLE OPTIONS
# focus events enabled for terminals that support them
tmux set-option -g focus-events on
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
fi
# super useful when using "grouped sessions" and multi-monitor setup
tmux set-window-option -g aggressive-resize on
# DEFAULT KEY BINDINGS
@ -132,7 +126,9 @@ main() {
fi
# pressing `prefix + prefix` sends <prefix> to the shell
tmux bind-key "$prefix" send-prefix
if key_binding_not_set "$prefix"; then
tmux bind-key "$prefix" send-prefix
fi
fi
# If Ctrl-a is prefix then `Ctrl-a + a` switches between alternate windows.
@ -151,7 +147,7 @@ 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 bind-key R run-shell ' \
tmux source-file ~/.tmux.conf > /dev/null; \
tmux display-message "Sourced .tmux.conf!"'
fi