diff options
Diffstat (limited to 'regress')
49 files changed, 3803 insertions, 0 deletions
diff --git a/regress/Makefile b/regress/Makefile new file mode 100644 index 00000000..e6c3619f --- /dev/null +++ b/regress/Makefile @@ -0,0 +1,10 @@ +TESTS!= echo *.sh + +.PHONY: all $(TESTS) +.NOTPARALLEL: all $(TESTS) + +all: $(TESTS) + +$(TESTS): + sh $*.sh + sleep 1 diff --git a/regress/am-terminal.sh b/regress/am-terminal.sh new file mode 100644 index 00000000..94033468 --- /dev/null +++ b/regress/am-terminal.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null +TMUX2="$TEST_TMUX -Ltest2" +$TMUX2 kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +$TMUX2 -f/dev/null new -d || exit 1 +$TMUX2 set -as terminal-overrides ',*:am@' || exit 1 +$TMUX2 set -g status-right 'RRR' || exit 1 +$TMUX2 set -g status-left 'LLL' || exit 1 +$TMUX2 set -g window-status-current-format 'WWW' || exit 1 +$TMUX -f/dev/null new -x20 -y2 -d "$TMUX2 attach" || exit 1 +sleep 1 +$TMUX capturep -p|tail -1 >$TMP || exit 1 +$TMUX kill-server 2>/dev/null +$TMUX2 kill-server 2>/dev/null +cat <<EOF|cmp -s $TMP - || exit 1 +LLLWWW RR +EOF + +exit 0 diff --git a/regress/capture-pane-sgr0.sh b/regress/capture-pane-sgr0.sh new file mode 100644 index 00000000..0dd9cd82 --- /dev/null +++ b/regress/capture-pane-sgr0.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# 884 +# capture-pane should send colours after SGR 0 + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +$TMUX -f/dev/null new -d " + printf '\033[31;42;1mabc\033[0;31mdef\n' + printf '\033[m\033[100m bright bg \033[m' + $TMUX capturep -peS0 -E1 >>$TMP" + + +sleep 1 + +( + printf '\033[1m\033[31m\033[42mabc\033[0m\033[31m\033[49mdef\033[39m\n' + printf '\033[100m bright bg \033[49m\n' +) | cmp - $TMP || exit 1 + +$TMUX has 2>/dev/null && exit 1 + +exit 0 diff --git a/regress/command-order.sh b/regress/command-order.sh new file mode 100644 index 00000000..04046f0d --- /dev/null +++ b/regress/command-order.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +cat <<EOF >$TMP +new -sfoo -nfoo0; neww -nfoo1; neww -nfoo2 +new -sbar -nbar0; neww -nbar1; neww -nbar2 +EOF +$TMUX -f$TMP start </dev/null || exit 1 +sleep 1 +$TMUX lsw -aF '#{session_name},#{window_name}'|sort >$TMP || exit 1 +$TMUX kill-server 2>/dev/null +cat <<EOF|cmp -s $TMP - || exit 1 +bar,bar0 +bar,bar1 +bar,bar2 +foo,foo0 +foo,foo1 +foo,foo2 +EOF + +cat <<EOF >$TMP +new -sfoo -nfoo0 +neww -nfoo1 +neww -nfoo2 +new -sbar -nbar0 +neww -nbar1 +neww -nbar2 +EOF +$TMUX -f$TMP start </dev/null || exit 1 +sleep 1 +$TMUX lsw -aF '#{session_name},#{window_name}'|sort >$TMP || exit 1 +$TMUX kill-server 2>/dev/null +cat <<EOF|cmp -s $TMP - || exit 1 +bar,bar0 +bar,bar1 +bar,bar2 +foo,foo0 +foo,foo1 +foo,foo2 +EOF + +exit 0 diff --git a/regress/conf-syntax.sh b/regress/conf-syntax.sh new file mode 100644 index 00000000..96d35140 --- /dev/null +++ b/regress/conf-syntax.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +for i in conf/*.conf; do + $TMUX -f/dev/null start \; source -n $i || exit 1 +done + +exit 0 diff --git a/regress/conf/21867280ff7e99631046f9cc669b80d2.conf b/regress/conf/21867280ff7e99631046f9cc669b80d2.conf new file mode 100644 index 00000000..43b142b4 --- /dev/null +++ b/regress/conf/21867280ff7e99631046f9cc669b80d2.conf @@ -0,0 +1,8 @@ +%if #{l:1} +set -g status-style fg=cyan,bg='#001040' +%elif #{l:1} +set -g status-style fg=white,bg='#400040' +%else +set -g status-style fg=white,bg='#800000' +%endif +bind ^X last-window diff --git a/regress/conf/29813ff35544434e2e64dc879a8dd274.conf b/regress/conf/29813ff35544434e2e64dc879a8dd274.conf new file mode 100644 index 00000000..d0bda4a2 --- /dev/null +++ b/regress/conf/29813ff35544434e2e64dc879a8dd274.conf @@ -0,0 +1,58 @@ +set -g prefix C-g +# needed for e.g. mutt +bind C-g send-prefix + +set -g set-titles on +set -g status-position top +set -g status-keys vi +set -g mode-keys vi +set -g base-index 1 +set -g pane-base-index 1 +set -g focus-events on + +set history-file ~/.tmux_SSH_history +set focus-events on +set -g history-limit 100000 +set -s set-clipboard on +set -g display-time 3000 +set -g display-panes-time 3000 + +set -g pane-border-status top + +setw -g window-status-current-style bg=colour240,fg=colour250 +setw -g window-status-separator "|" +set -g status-bg colour235 +set -g status-fg colour245 + +set -g window-status-format " #I #{=+15:pane_title} #{=-2:?window_flags, #{window_flags}, }" +set -g window-status-current-format " #I #{=+15:pane_title} #{=-2:?window_flags, #{window_flags}, }" +set -g pane-border-format " #P: #{s/ //:pane_title} " + +set -g renumber-windows on +set -g status-right-length 0 +############################################################## + +# I prefer not to have a status for my tabbed term +set -g status-right "" +set -g status-right-length 0 +set -g status-left-length 0 +set -g status-left "" + +# some settings for "navigation" +bind -n C-PageUp copy-mode -u +unbind -n C-Left +unbind -n C-Right +bind -n C-Left select-window -t :- +bind -n C-Right select-window -t :+ + +# I prefer a tiled layout and easy joining of current active pane via windows' +# index +bind F1 join-pane -s 1.\; select-layout tiled +bind F2 join-pane -s 2.\; select-layout tiled +bind F3 join-pane -s 3.\; select-layout tiled +bind F4 join-pane -s 4.\; select-layout tiled +bind F5 join-pane -s 5.\; select-layout tiled +bind F6 join-pane -s 6.\; select-layout tiled +bind F7 join-pane -s 7.\; select-layout tiled +bind F8 join-pane -s 8.\; select-layout tiled +bind F9 join-pane -s 9.\; select-layout tiled diff --git a/regress/conf/2e0f96ac3e1c144ce48261a4c9d68a48.conf b/regress/conf/2e0f96ac3e1c144ce48261a4c9d68a48.conf new file mode 100644 index 00000000..df4c2b1c --- /dev/null +++ b/regress/conf/2e0f96ac3e1c144ce48261a4c9d68a48.conf @@ -0,0 +1,25 @@ +bind -r Up if -F '#{pane_at_top}' '' 'selectp -U' +bind -r Down if -F '#{pane_at_bottom}' '' 'selectp -D' +bind -r Left if -F '#{pane_at_left}' '' 'selectp -L' +bind -r Right if -F '#{pane_at_right}' '' 'selectp -R' + +bind -n WheelUpPane if -Ft= "#{mouse_any_flag}" "send -M" "send Up" +bind -n WheelDownPane if -Ft= "#{mouse_any_flag}" "send -M" "send Down" + +bind w run 'tmux choose-tree -Nwf"##{==:##{session_name},#{session_name}}"' + +bind C { + splitw -f -l30% '' + set-hook -p pane-mode-changed 'if -F "#{!=:#{pane_mode},copy-mode}" "kill-pane"' + copy-mode -s'{last}' +} + +bind -n C-DoubleClick1Pane if -F '#{m/r:^[^:]*:[0-9]+:,#{mouse_word}}' { + popup -w90% -h90% -KE -d '#{pane_current_path}' -R { + emacs `echo #{mouse_word}|awk -F: '{print "+" $2,$1}'` + } +} { + popup -w90% -h90% -KE -d '#{pane_current_path}' -R { + emacs "#{mouse_word}" + } +} diff --git a/regress/conf/2eae5d47049c1f6d0bef3db4e171aed7.conf b/regress/conf/2eae5d47049c1f6d0bef3db4e171aed7.conf new file mode 100644 index 00000000..c09adc24 --- /dev/null +++ b/regress/conf/2eae5d47049c1f6d0bef3db4e171aed7.conf @@ -0,0 +1,56 @@ +# 256 colors for vim +set -g default-terminal "screen-256color" + +# Set default shell to zsh +set-option -g default-shell /bin/zsh + +# Start window numbering at 1 +set-option -g base-index 1 +set-window-option -g pane-base-index 1 + +# Cycle panes with C-b C-b +unbind ^B +bind ^B select-pane -t :.+ + +# Reload config wtih a key +bind-key r source-file ~/.tmux.conf \; display "Config reloaded!" + +# Mouse works as expected +# set -g mode-mouse on +# set -g mouse-select-pane on +# set -g mouse-resize-pane on +# set -g mouse-select-window on + +# Scrolling works as expected +set -g terminal-overrides 'xterm*:smcup@:rmcup@' + +# Use the system clipboard +# set-option -g default-command "reattach-to-user-namespace -l zsh" + +# Clear the pane and its history +bind -n C-k send-keys C-l \; clear-history + +# smart pane switching with awareness of vim splits +bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" +bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" +bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" +bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" +bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l" + +# C-l is taken oer by vim style pane navigation +bind C-l send-keys 'C-l' + +# Use vim keybindings in copy mode +setw -g mode-keys vi + +# Setup 'v' to begin selection as in Vim +# bind-key -t vi-copy v begin-selection +# bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" + +# Update default binding of `Enter` to also use copy-pipe +# unbind -t vi-copy Enter +# bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy" + +# Powerline +run-shell "powerline-daemon -q" +source "/Users/adamcooper/Library/Python/3.7/lib/python/site-packages/powerline/bindings/tmux/powerline.conf"
\ No newline at end of file diff --git a/regress/conf/327af72ad372255817b585a74da06eda.conf b/regress/conf/327af72ad372255817b585a74da06eda.conf new file mode 100644 index 00000000..2a719c8b --- /dev/null +++ b/regress/conf/327af72ad372255817b585a74da06eda.conf @@ -0,0 +1,30 @@ +set -sg escape-time 10 + +set -g default-terminal tmux-256color +set -g prefix ^X +set -g history-limit 10000 +setw -g mode-keys vi +setw -g xterm-keys off + +# black, red, green, yellow, blue, magenta, cyan, white, default. +setw -g message-command-style fg=yellow,bg=black +setw -g message-style fg=black,bg=yellow + +%if #{m:*mydomain*,#{host}} +set -g status-style fg=cyan,bg='#001040' +setw -g window-status-current-style fg='#f0f0f0',bg='#001040' +%elif #{||:#{m:*somedomain*,#{host}},#{m:*otherdomain*,#{host}}} +set -g status-style fg=white,bg='#400040' +setw -g window-status-current-style fg=yellow,bg='#400040',bright +%else +set -g status-style fg=white,bg='#800000' +setw -g window-status-current-style fg=brightwhite,bg='#800000' +%endif + +unbind ^B +bind ^X last-window +bind x send-prefix +bind ^C new-window +bind ^D detach-client +bind ^N next-window +bind ^P previous-window diff --git a/regress/conf/58304907c117cab9898ea0b070bccde3.conf b/regress/conf/58304907c117cab9898ea0b070bccde3.conf new file mode 100644 index 00000000..c9ce3fa4 --- /dev/null +++ b/regress/conf/58304907c117cab9898ea0b070bccde3.conf @@ -0,0 +1,118 @@ +# +# Tureba's tmux.conf +# +# To use it, either: +# a) link ~/.tmux.conf to it; or +# b) create a ~/.tmux.conf that sources it. +# +# who: Arthur Nascimento <tureba@gmail.com> +# where: github.com/tureba/myconfigfiles +# + +# defaults +set -g default-shell /bin/zsh +set -g default-command zsh +# tmux sets screen/screen-256, but has no codes for italics +set -g default-terminal tmux-256color +# linux terminal doesn't need this, but xterm does +set -g terminal-overrides 'xterm*:smcup@:rmcup@,*256col*:colors=256,xterm*:XT' +# xterm-style function key sequences +setw -g xterm-keys on + +# 1, 2 and 3 are closer together than 0, 1 and 2 +set -g base-index 1 +set -g pane-base-index 1 + +# easier to type than C-b +set -g prefix C-a +set -g prefix2 C-b +unbind C-b +bind C-a send-prefix + +# for repeatable keys +set -g repeat-time 170 + +# status bar +set -g status-style fg=green,bg=colour234 +set -g status-right-style bg=colour236 +set -g status-right "#[bold,fg=blue][#[fg=default]#T#[fg=blue]]#[nobold,fg=default] | #[fg=yellow]%F %R" +set -g status-right-length 120 +set -g status-left-style bg=colour236,bright +set -g status-left "#[fg=blue][#[fg=default]#h#[fg=cyan]:#[fg=default]#S#[fg=blue]]" +set -g status-left-length 30 +setw -g window-status-style fg=green +setw -g window-status-format " #I#[nobold]:#W " +setw -g window-status-current-style fg=green,bright +setw -g window-status-current-format "#[fg=red][#[fg=default]#I:#W#[fg=red]]" +setw -g window-status-separator "|" +setw -g window-status-activity-style blink +setw -g window-status-bell-style blink +setw -g window-status-last-style bright + +# enable wm window titles +set -g set-titles on + +# auto window rename +setw -g automatic-rename on +# auto window resize +setw -g aggressive-resize on + +# mouse settings +set -g mouse on + +# var|bind \ cmd | vim | less | copy | zsh +# pane_in_mode | 0 | 0 | 1 | 0 +# mouse_any_flag | 1 | 0 | 0 | 0 +# alternate_on | 1 | 1 | 0 | 0 +# WheelUpPane | send -M | send Up | * | send Up (** or copy-mode -e) +# WheelDownPane | send -M | send Down | * | send Down +# * panes in copy mode have scroll handled by different bindings + +# ** cycle over shell history +#bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'send -Mt=' 'send -t= Up' + +# ** enter copy mode +bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'send -Mt=' 'if -Ft= "#{alternate_on}" "send -t= Up" "copy-mode -et="' + +bind -T root WheelDownPane if -Ft= '#{mouse_any_flag}' 'send -Mt=' 'send -t= Down' + +# sensible v/h splits +unbind % +unbind '"' +bind | split-window -h +bind - split-window -v + +# hjkl pane traversal +bind -r h select-pane -L +bind -r j select-pane -D +bind -r k select-pane -U +bind -r l select-pane -R + +# window navigation +unbind p +bind -r [ previous-window +unbind n +bind -r ] next-window + +# Vi copypaste mode +setw -g mode-keys vi +bind C-c copy-mode +bind p paste-buffer +bind -T copy-mode-vi v send-keys -X begin-selection +bind -T copy-mode-vi y send-keys -X copy-selection +bind -T copy-mode-vi V send-keys -X rectangle-toggle + +# toggle window activity monitoring +bind m setw monitor-activity + +# reload the configuration +bind r source-file ~/.tmux.conf + +# toggle synchronize-panes +bind S setw synchronize-panes + +# create a new window with exactly this command +bind C command-prompt "new-window 'exec %%'" + +# (toggle) mark this pane for easier joins and swaps +bind . select-pane -m diff --git a/regress/conf/91378fd400b0444eb8cac471e30642b3.conf b/regress/conf/91378fd400b0444eb8cac471e30642b3.conf new file mode 100644 index 00000000..40810076 --- /dev/null +++ b/regress/conf/91378fd400b0444eb8cac471e30642b3.conf @@ -0,0 +1,30 @@ +### + +if-shell " \ + tmux -V \ + | awk '{print $2}' \ + | awk -F - '{print $1}' \ + | awk '{ \ + if ($1 ~ /^[[:digit:].]+$/) { \ + exit !($1 >= 2.6) \ + } else { \ + exit !($1 == \"master\" || $1 == \"next\") \ + } \ + }'" \ + "source-file ~/.tmux/v2rc" \ + "source-file ~/.tmux/v1rc" \ + ; + +### + +set-option -qg status-left \ + "[#[fg=yellow]#{session_name}#[default]] #[fg=colour060]#{host_short}#[default]:#[fg=colour151]#{b:pane_current_path} #[fg=colour099]#(git -C #{pane_current_path} symbolic-ref --short HEAD) #[fg=green]#(git -C #{pane_current_path} status --porcelain --untracked-files=no | cut -b 1-1 | sort | uniq | awk '/^[^[:space:]]/ {printf\(\"%%s\", $0\)}')#[fg=red]#(git -C #{pane_current_path} status --porcelain --untracked-files=no | cut -b 2-2 | sort | uniq | awk '/^[^[:space:]]/ {printf\(\"%%s\", $0\)}')#[fg=colour113]#(git -C #{pane_current_path} stash list 2>/dev/null | wc -l | tr -d '\n' | sed s,^0\$,,) #[default]" + +set-option -qg status-right \ + "#[default] ┊ #[fg=colour065]#(grep ^MemFree /proc/meminfo | awk '{print rshift\($2, 10\)}')#[fg=colour071]m #[default]┊ #[fg=colour101]#(echo \"\(`awk '{print \$1}' /proc/loadavg` / `grep ^processor /proc/cpuinfo | wc -l`\) \* 100\" | bc -ql | sed 's,\\..*,,' | awk '{printf\(\"%%2u\", $0\)}')#[fg=colour102]%% " + +set-option -qwg window-status-current-format \ + "#[fg=colour208]»#[fg=colour190]#{window_name}#[fg=colour037]·#{?window_flags,#[fg=colour058]#{window_flags}#[default], #[default]}" + +set-option -qwg window-status-format \ + "#[default]»#[fg=colour066]#{window_name}#[fg=colour037]·#{?window_flags,#[fg=colour058]#{window_flags}#[default], #[default]}" diff --git a/regress/conf/99749670b62bcb99a9b2e3d59708e357.conf b/regress/conf/99749670b62bcb99a9b2e3d59708e357.conf new file mode 100644 index 00000000..dd1700b0 --- /dev/null +++ b/regress/conf/99749670b62bcb99a9b2e3d59708e357.conf @@ -0,0 +1,93 @@ +# ----------------------------------------------------------------------------- +# This config is targeted for tmux 2.1+ and should be placed in $HOME. +# +# Read the "Plugin Manager" section (bottom) before trying to use this config! +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# Global options +# ----------------------------------------------------------------------------- + +# Set a new prefix / leader key. +set -g prefix ` +bind ` send-prefix + +# Allow opening multiple terminals to view the same session at different sizes. +setw -g aggressive-resize on + +# Remove delay when switching between Vim modes. +set -s escape-time 0 + +# Allow Vim's FocusGained to work when your terminal gains focus. +# Requires Vim plugin: https://github.com/tmux-plugins/vim-tmux-focus-events +set -g focus-events on + +# Add a bit more scroll history in the buffer. +set -g history-limit 50000 + +# Enable color support inside of tmux. +set -g default-terminal "screen-256color" + +# Ensure window titles get renamed automatically. +setw -g automatic-rename + +# Start windows and panes index at 1, not 0. +set -g base-index 1 +setw -g pane-base-index 1 + +# Enable full mouse support. +set -g mouse on + +# Status bar optimized for Gruvbox. +set -g status-fg colour244 +set -g status-bg default +set -g status-left '' +set -g status-right-length 0 +#set -g status-right-length 20 +#set -g status-right '%a %Y-%m-%d %H:%M' + +set -g pane-border-fg default +set -g pane-border-bg default +set -g pane-active-border-fg colour250 +set -g pane-active-border-bg default + +set-window-option -g window-status-current-attr bold +set-window-option -g window-status-current-fg colour223 + +# ----------------------------------------------------------------------------- +# Key bindings +# ----------------------------------------------------------------------------- + +# Unbind default keys +unbind C-b +unbind '"' +unbind % + +# Reload the tmux config. +bind-key r source-file ~/.tmux.conf + +# Split panes. +bind-key h split-window -v +bind-key v split-window -h + +# Move around panes with ALT + arrow keys. +bind-key -n M-Up select-pane -U +bind-key -n M-Left select-pane -L +bind-key -n M-Down select-pane -D +bind-key -n M-Right select-pane -R + +# ----------------------------------------------------------------------------- +# Plugin Manager - https://github.com/tmux-plugins/tpm +# In order to use the plugins below you need to install TPM and the plugins. +# Step 1) git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm +# Step 2) Reload tmux if it's already started with `r +# Step 3) Launch tmux and hit `I (capital i) to fetch any plugins +# ----------------------------------------------------------------------------- + +# List of plugins. +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-yank' + +# Initialize TPM (keep this line at the very bottom of your tmux.conf). +run -b '~/.tmux/plugins/tpm/tpm' diff --git a/regress/conf/a46e6e84cd1071105aa807256dbc158d.conf b/regress/conf/a46e6e84cd1071105aa807256dbc158d.conf new file mode 100644 index 00000000..bfbb2d3e --- /dev/null +++ b/regress/conf/a46e6e84cd1071105aa807256dbc158d.conf @@ -0,0 +1,432 @@ +# Dynamic configuration file generated by ~/Makefile from /home/sunny/.tmux.conf.erb +# +# DO NOT EDIT THIS FILE BY HAND -- +# YOUR CHANGES WILL BE OVERWRITTEN +# + + + +bind-key R source ~/.tmux.conf \; display-message 'config reloaded!' + +#----------------------------------------------------------------------------- +# terminal +#----------------------------------------------------------------------------- + +# enable mouse support for general selection and control +set-option -g mouse on + +# auto-set terminal title to current window pane's title +set-option -g set-titles on + +# enable 256-color support for pretty colorschemes in Vim +set-option -g default-terminal 'screen-256color' + +# allow Vim to receive focus events from terminal window +set-option -g focus-events on + +# allow Vim to recieve modifier keys: Shift, Control, Alt +set-window-option -g xterm-keys on + +# prevent tmux from catching modifier keys meant for Vim +set-option -s escape-time 0 + +# enable 24-bit true color RGB escape sequences under st +# https://sunaku.github.io/tmux-24bit-color.html +set-option -ga terminal-overrides ',st-256color:Tc' +set-option -ga terminal-overrides ',xterm-256color:Tc' # hterm (ChromeOS) + +# allow set-titles to change the window title under XTerm +# http://opennomad.com/content/goodbye-screen-hello-tmux +set-option -ga terminal-overrides ',xterm*:XT' + +# allow set-titles to change the window title under XTerm +# http://opennomad.com/content/goodbye-screen-hello-tmux +# http://stackoverflow.com/questions/15195624 +set-option -ga terminal-overrides ',st-256color:smkx=\E=' + +# yank to system clipboard rather than primary selection +# http://invisible-island.net/xterm/terminfo-contents.html#tic-xterm_tmux +set-option -ga terminal-overrides ',xterm*:Ms=\E]52;c;%p2%s\007' + +# KiTTY always appends to clipboard; must clear it first +# https://sw.kovidgoyal.net/kitty/protocol-extensions.html#pasting-to-clipboard +set-option -ga terminal-overrides ',xterm-kitty:Ms=\E]52;c;!\007\E]52;c;%p2%s\007' + +# prevent standout from appearing as italics under URxvt +# http://comments.gmane.org/gmane.comp.terminal-emulators.tmux.user/1927 +set-option -ga terminal-overrides ',rxvt-unicode*:sitm@' + +#----------------------------------------------------------------------------- +# appearance +#----------------------------------------------------------------------------- + +# Colors from the "lucius" and "gruvbox" themes in the vim-airline plugin: +# https://github.com/bling/vim-airline/blob/master/autoload/airline/themes/lucius.vim +# https://github.com/morhetz/gruvbox/blob/master/autoload/airline/themes/gruvbox.vim + +set-option -g status-style fg=colour246,bg=colour237 +set-window-option -g window-status-current-style fg=colour214,bg=colour239 +set-option -g pane-border-style fg=colour239 +set-option -g pane-active-border-style fg=colour208 +set-option -g message-style fg=colour214,bg=colour239 +set-window-option -g mode-style fg=colour214,bg=colour239,bold,reverse + +# Common UI interaction cues from Blueprint CSS: +# http://blueprintcss.org/tests/parts/forms.html +set-window-option -g window-status-bell-style 'bg=#205791,fg=#d5edf8' # info (blue) +set-window-option -g window-status-activity-style 'bg=#8a1f11,fg=#fbe3e4' # error (red) + +#----------------------------------------------------------------------------- +# status bar +#----------------------------------------------------------------------------- + +# toggle status bar visibility +bind-key -n M-` set-option -g status + +# toggle status bar position +bind-key -n M-~ \ + if-shell 'tmux show-option -g status-position | grep -q top$' \ + 'set-option -g status-position bottom' \ + 'set-option -g status-position top' + +# put status bar at the top of the screen +set-option -g status-position top + +# list windows on left side of status bar +set-option -g status-left-length 0 + +# make window list easier to scan +set-window-option -g window-status-format ' #[bold]#I#F#[nobold]#W ' +set-window-option -g window-status-current-format ' #[bold]#I#F#[nobold]#W ' +set-window-option -g window-status-separator '' + +# show pane title, pane identifier, and hostname on right side of status bar +set-option -g status-right-length 64 +set-option -g status-right '#{=32:pane_title} \ +#[fg=colour214,bg=colour239] #S:#I.#P \ +#(test -n "$SSH_TTY" && echo "#[fg=colour214,bg=colour239,bold,reverse] #H ")' + +#----------------------------------------------------------------------------- +# windows +#----------------------------------------------------------------------------- + +# create window +bind-key -n M-e new-window + +# rename window +bind-key -n M-E command-prompt -I '#W' 'rename-window "%%%"' + +set-window-option -g automatic-rename off + + +# break off pane to a new window +bind-key -n M-x \ + command-prompt -p 'break-pane:' -I '#W' \ + 'break-pane ; rename-window "%%%"' +bind-key -n M-X break-pane + +# focus window +bind-key -n M-, previous-window +bind-key -n M-. next-window +bind-key -n M-o last-window + +# focus by number +set-option -g base-index 1 +set-window-option -g pane-base-index 1 +set-option -g renumber-windows on +bind-key -n M-0 choose-window +bind-key -n M-1 select-window -t :1 +bind-key -n M-2 select-window -t :2 +bind-key -n M-3 select-window -t :3 +bind-key -n M-4 select-window -t :4 +bind-key -n M-5 select-window -t :5 +bind-key -n M-6 select-window -t :6 +bind-key -n M-7 select-window -t :7 +bind-key -n M-8 select-window -t :8 +bind-key -n M-9 select-window -t :1 \; select-window -t :-1 + +# swap window +bind-key -n M-< swap-window -t :-1 +bind-key -n M-> swap-window -t :+1 + +# monitor window +set-option -g visual-activity on +set-option -g visual-silence on + + +bind-key -n M-k \ + set-window-option monitor-activity \;\ + display-message 'monitor-activity #{?monitor-activity,on,off}' + +bind-key -n M-K \ + if-shell 'tmux show-window-option -g monitor-activity | grep -q off$' \ + 'set-window-option -g monitor-activity on' \ + 'set-window-option -g monitor-activity off' \;\ + display-message 'monitor-activity #{?monitor-activity,on,off} (global)' + +bind-key -n M-j \ + command-prompt -p 'monitor-silence (seconds):' -I '#{monitor-silence}' \ + 'set-window-option monitor-silence %% ;\ + display-message "monitor-silence #{?monitor-silence,on,off}"' + +#----------------------------------------------------------------------------- +# panes +#----------------------------------------------------------------------------- + +# send input to all panes in window (toggle) +bind-key C-a \ + set-option synchronize-panes \;\ + display-message 'synchronize-panes #{?synchronize-panes,on,off}' + +# clear the screen in all panes in window +bind-key C-l \ + set-option synchronize-panes on \;\ + send-keys C-l \;\ + set-option synchronize-panes off + +# create pane (below, above, left, right) +bind-key -n M-c split-window -c '#{pane_current_path}' +bind-key -n M-C split-window -c '#{pane_current_path}' -b +bind-key -n M-R split-window -c '#{pane_current_path}' -b -h +bind-key -n M-r split-window -c '#{pane_current_path}' -h + +# join pane (above, left, below, right) +bind-key -n M-g move-pane -t .-1 -s . # join pane at bottom of prev pane +bind-key -n M-l move-pane -t .-1 -s . -h # join pane at right of prev pane +bind-key -n M-G move-pane -d -s .+1 -t . # join next pane at bottom +bind-key -n M-L move-pane -d -s .+1 -t . -h # join next pane at right + +# Intelligently navigate tmux panes and Vim splits using the same keys. +# See https://sunaku.github.io/tmux-select-pane.html for documentation. +# +# +-------------+------------+-----------------------------+ +# | inside Vim? | is Zoomed? | Action taken by key binding | +# +-------------+------------+-----------------------------+ +# | No | No | Focus directional tmux pane | +# | No | Yes | Nothing: ignore key binding | +# | Yes | No | Seamlessly focus Vim / tmux | +# | Yes | Yes | Focus directional Vim split | +# +-------------+------------+-----------------------------+ +# +vim_navigation_timeout=0.05 # number of seconds we give Vim to navigate +navigate=' \ + pane_is_zoomed() { \ + test #{window_zoomed_flag} -eq 1; \ + }; \ + pane_title_changed() { \ + test "#{pane_title}" != "$(tmux display -p "##{pane_title}")"; \ + }; \ + command_is_vim() { \ + case "${1%% *}" in \ + (vi|?vi|vim*|?vim*|view|?view|vi??*) true ;; \ + (*) false ;; \ + esac; \ + }; \ + pane_contains_vim() { \ + case "#{=3:pane_current_command}" in \ + (git|ssh|sh) command_is_vim "#{=5:pane_title}" ;; \ + (*) command_is_vim "#{=5:pane_current_command}" ;; \ + esac; \ + }; \ + pane_contains_neovim_terminal() { \ + test "#{=12:pane_title}" = "nvim term://"; \ + }; \ + navigate() { \ + tmux_navigation_command=$1; \ + vim_navigation_command=$2; \ + vim_navigation_only_if=${3:-true}; \ + if pane_contains_vim && eval "$vim_navigation_only_if"; then \ + if pane_contains_neovim_terminal; then \ + tmux send-keys C-\\ C-n; \ + fi; \ + eval "$vim_navigation_command"; \ + if ! pane_is_zoomed; then \ + sleep $vim_navigation_timeout; : wait for Vim to change title; \ + if ! pane_title_changed; then \ + eval "$tmux_navigation_command"; \ + fi; \ + fi; \ + elif ! pane_is_zoomed; then \ + eval "$tmux_navigation_command"; \ + fi; \ + }; \ +navigate ' +navigate_left=" $navigate 'tmux select-pane -L' 'tmux send-keys C-w h'" +navigate_down=" $navigate 'tmux select-pane -D' 'tmux send-keys C-w j'" +navigate_up=" $navigate 'tmux select-pane -U' 'tmux send-keys C-w k'" +navigate_right="$navigate 'tmux select-pane -R' 'tmux send-keys C-w l'" +navigate_back=" $navigate 'tmux select-pane -l || tmux select-pane -t1'\ + 'tmux send-keys C-w p' \ + 'pane_is_zoomed' " + +## QWERTY keys - comment these out if you don't use QWERTY layout! +#bind-key -n M-h run-shell -b "$navigate_left" +#bind-key -n M-j run-shell -b "$navigate_down" +#bind-key -n M-k run-shell -b "$navigate_up" +#bind-key -n M-l run-shell -b "$navigate_right" +#bind-key -n M-\ run-shell -b "$navigate_back" + +# Dvorak keys - comment these out if you don't use Dvorak layout! +bind-key -n M-d run-shell -b "$navigate_back" +bind-key -n M-h run-shell -b "$navigate_left" +bind-key -n M-t run-shell -b "$navigate_up" +bind-key -n M-n run-shell -b "$navigate_down" +bind-key -n M-s run-shell -b "$navigate_right" + +# resize pane +bind-key -r H resize-pane -L 5 +bind-key -r T resize-pane -U 5 +bind-key -r N resize-pane -D 5 +bind-key -r S resize-pane -R 5 + +# zoom pane +bind-key -n M-m resize-pane -Z + +# swap pane +bind-key -n M-- swap-pane -D +bind-key -n M-_ swap-pane -U +bind-key -n M-D run-shell 'tmux select-pane -l \; swap-pane -d -s #D' +bind-key -n M-H run-shell 'tmux select-pane -L \; swap-pane -d -s #D' +bind-key -n M-T run-shell 'tmux select-pane -U \; swap-pane -d -s #D' +bind-key -n M-N run-shell 'tmux select-pane -D \; swap-pane -d -s #D' +bind-key -n M-S run-shell 'tmux select-pane -R \; swap-pane -d -s #D' + +# attach by number +bind-key -n 'M-!' join-pane -t :1 +bind-key -n 'M-@' join-pane -t :2 +bind-key -n 'M-#' join-pane -t :3 +bind-key -n 'M-$' join-pane -t :4 +bind-key -n 'M-%' join-pane -t :5 +bind-key -n 'M-^' join-pane -t :6 +bind-key -n 'M-&' join-pane -t :7 +bind-key -n 'M-*' join-pane -t :8 +bind-key -n 'M-(' run-shell 'tmux select-window -t :1 \;\ + select-window -t :-1 \;\ + join-pane -s "#{pane_id}"' +bind-key -n 'M-)' choose-window 'join-pane -t "%%%"' + +# promote pane (toggle) +bind-key -n M-Enter \ + if-shell 'test #P -ne 1' \ + 'select-pane -t 1' \ + 'last-pane; swap-pane -s 1' + +# rotate panes +bind-key -n M-a rotate-window -D +bind-key -n M-A rotate-window -U + +#----------------------------------------------------------------------------- +# layouts +#----------------------------------------------------------------------------- + +bind-key M-w select-layout main-horizontal +bind-key M-W select-layout even-vertical +bind-key M-v select-layout main-vertical +bind-key M-V select-layout even-horizontal +bind-key M-z select-layout tiled + +# half-screen tiling layouts (horizontal, vertical) +# https://sunaku.github.io/tmux-half-screen-tiling-layouts.html +bind-key -n M-w select-layout main-horizontal \;\ + run-shell 'tmux resize-pane -t 1 -y $(( #{window_height} / 2 ))' +bind-key -n M-v select-layout main-vertical \;\ + run-shell 'tmux resize-pane -t 1 -x $(( #{window_width} / 2 ))' + +# binary space partitioned layouts (dwindle, spiral) +# https://sunaku.github.io/tmux-layout-dwindle.html +bind-key -n M-w run-shell 'tmux-layout-dwindle brhc && tmux-redraw-vim' +bind-key -n M-W run-shell 'tmux-layout-dwindle trhc && tmux-redraw-vim' +bind-key -n M-v run-shell 'tmux-layout-dwindle brvc && tmux-redraw-vim' +bind-key -n M-V run-shell 'tmux-layout-dwindle blvc && tmux-redraw-vim' +bind-key -n M-z select-layout tiled + +#----------------------------------------------------------------------------- +# scrollback buffer +#----------------------------------------------------------------------------- + +# buffer length +set-option -g history-limit 32767 + +# search buffer using copy mode +bind-key -n M-/ copy-mode \;\ + command-prompt -p 'search-backward (press up):' \ + -i 'send-keys -X search-backward-incremental "%%%"' + +# search buffer using Vim or less +bind-key -n M-| \ + capture-pane -J -S - \; \ + new-window -n '#S:#I.#P' -a ' \ + tmux save-buffer - \; delete-buffer | { \ + if command -v vim; \ + then vim -R -c "set nofen is hls ic" -; \ + else less; \ + fi; \ + }; \ + ' \; \ + run-shell 'tmux send-keys G \?' + +# search colored buffer using less +bind-key -n M-? \ + capture-pane -e -J -S - \; \ + new-window -n '#S:#I.#P' -a ' \ + tmux save-buffer - \; delete-buffer | \ + less -R \ + ' \; \ + run-shell 'tmux send-keys G \?' + +# scroll buffer +# NOTE: set "URxvt.saveLines: 0" in ~/.Xdefaults to make Shift+PageUp bindable +# NOTE: see http://aperiodic.net/screen/interface for doing the same in XTerm +bind-key -n S-PPage copy-mode -u + +# copy text from buffer +bind-key -n M-u copy-mode +set-window-option -g mode-keys vi +bind-key -T copy-mode-vi v send-keys -X begin-selection +bind-key -T copy-mode-vi y send-keys -X copy-selection +bind-key -T copy-mode-vi - send-keys -X jump-again +bind-key -T copy-mode-vi _ send-keys -X jump-reverse +bind-key -T copy-mode-vi ? command-prompt -p 'search-backward:' -I '#{pane_search_string}' -i 'send-keys -X search-backward-incremental "%%%"' +bind-key -T copy-mode-vi / command-prompt -p 'search-forward:' -I '#{pane_search_string}' -i 'send-keys -X search-forward-incremental "%%%"' + +# transfer copied text to attached terminal with yank: +# https://github.com/sunaku/home/blob/master/bin/yank +bind-key -T copy-mode-vi Y send-keys -X copy-pipe 'yank > #{pane_tty}' +# open the visual selection with xdg-open(1) +bind-key -T copy-mode-vi O send-keys -X copy-pipe 'xargs -r xdg-open' + +# paste most-recently copied text +bind-key -n M-i paste-buffer + +# paste previously copied text (chosen from a menu) +bind-key -n M-I choose-buffer + +# transfer most-recently copied text to attached terminal with yank: +# https://github.com/sunaku/home/blob/master/bin/yank +bind-key -n M-y run-shell 'tmux save-buffer - | yank > #{pane_tty}' + +# transfer previously copied text (chosen from a menu) to attached terminal: +# https://github.com/sunaku/home/blob/master/bin/yank +bind-key -n M-Y choose-buffer 'run-shell "tmux save-buffer -b \"%%%\" - | yank > #{pane_tty}"' + +#----------------------------------------------------------------------------- +# TMUX plugin manager https://github.com/tmux-plugins/tpm +#----------------------------------------------------------------------------- + +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @resurrect-capture-pane-contents on + +set -g @plugin 'Morantron/tmux-fingers' +set -g @fingers-key '-n M-U' +set -g @fingers-compact-hints 1 +set -g @fingers-hint-format '#[fg=yellow,bold,reverse]%s' +set -g @fingers-hint-labels ' \ + a o e u i d h t n s \ + p y f g c r l \ + q j k x b m w v z \ + A O E U I D H T N S \ + P Y F G C R L \ + Q J K X B M W V Z \ +' + +run-shell ~/.tmux/plugins/tpm/tpm diff --git a/regress/conf/a4789a6782859c66aa8c9614ee6fabfa.conf b/regress/conf/a4789a6782859c66aa8c9614ee6fabfa.conf new file mode 100644 index 00000000..7f4a8cd1 --- /dev/null +++ b/regress/conf/a4789a6782859c66aa8c9614ee6fabfa.conf @@ -0,0 +1,80 @@ +set -g default-command "if [ \"$(uname)\" = 'Darwin' ]; then exec reattach-to-user-namespace $SHELL; else exec $SHELL; fi" +set -g history-limit 32000 +set -g update-environment "DISPLAY WINDOWID SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION SSH_CLIENT SSH_TTY KRB5CCNAME Apple_PubSub_Socket_Render Apple_Ubiquity_Message" + +# Reset SHLVL (otherwise it is 2 inside tmux) +setenv -g SHLVL 0 + +# Send esc faster so that neovim won't get so laggy +# https://github.com/neovim/neovim/issues/2093 +set -g escape-time 100 + +# Disable paste detection +set -g assume-paste-time 0 + +# Titles and window names +set -g set-titles on +set -g set-titles-string "#T" + +# Make it not so annoying/sticky to switch windows +set -g repeat-time 170 + +# Don't deattach me when a session ends +set -g detach-on-destroy off + +# Make shift+keys work +setw -g xterm-keys on + +# Prefix +set -g prefix ^A +unbind ^B +bind ^A send-prefix +bind a send-prefix + +# Last window +bind ^a last + +# Next & prev +bind ' ' next +bind '^ ' next +bind ^p prev + +# Status +set -g status off +# Need more (cow)bells! +set -g bell-action any +set -g bell-on-alert on + +# Detach +bind ^d detach + +# Control the a tmux in a tmux +bind A send-prefix \; send-prefix +bind C send-prefix \; send-keys c +bind n send-prefix \; send-keys ' ' +bind bspace send-prefix \; send-keys p +bind '#' send-prefix \; send-keys '"' + +# Other key bindings. +bind ^r command-prompt "find-window '%%'" +bind '"' choose-tree -w +bind w split-window +bind W split-window -c "#{pane_current_path}" +bind ^w split-window +bind I list-windows +bind i list-windows +bind D neww 'if who | grep -q "$USER.* via mosh"; then tmux lsc -F "#{client_activity} #{client_tty}" | sort | head -n -1 | awk "{print \$2}" | xargs -n1 tmux detach -t; else for i in $(tmux lsc | cut -d: -f1 | grep -v "^$SSH_TTY$"); do tmux detach -t $i; done; fi' +bind S neww -t 999 'window=`tmux display -p "#{pane_title}"`; i=0; tmux list-windows | cut -d: -f1 | while read j; do if [ $j != $i ]; then tmux move-window -s $j -t $i; fi; i=$(($i+1)); done' # ; tmux find-window -T "$window" +bind ^s command-prompt "rename-session '%%'" +# Make the default HOME always ~ +bind c neww -c ~ +bind ^c new -c ~ +bind escape copy-mode +# Copy to the OS clipboard +bind -T copy-mode-vi y send -X copy-pipe-and-cancel "if [ \"$(uname)\" = 'Darwin' ]; then reattach-to-user-namespace pbcopy; else xclip; fi" +bind j command-prompt "join-pane -s '%%'" +bind ! break-pane -d +bind - command-prompt "move-pane -t '%%'" + +# Makes `tmux a` work even when there isn't a session going on +new-session -A -c ~ diff --git a/regress/conf/ad0537c4e83d7a25d5dc4f3a3c571349.conf b/regress/conf/ad0537c4e83d7a25d5dc4f3a3c571349.conf new file mode 100644 index 00000000..ce68c4ab --- /dev/null +++ b/regress/conf/ad0537c4e83d7a25d5dc4f3a3c571349.conf @@ -0,0 +1,65 @@ +set-option -g allow-rename on +set-option -g automatic-rename off +set-option -g base-index 1 +set-option -g default-command "$SHELL" +set-option -g default-terminal "tmux-256color" +set-option -g history-limit 25000 +set-option -g mode-keys vi +set-option -g prefix C-f +set-option -g renumber-windows yes +set-option -g set-titles on +set-option -g set-titles-string "#T" +set-option -g xterm-keys on + +set-option -g status-interval 1 +set-option -g status-left "#(tmux-status-left)" +set-option -g status-left-length 40 +set-option -g status-right "" + +set-option -g window-status-current-attr bold +set-option -g window-status-current-format "[#I#F#{?window_zoomed_flag, ,}#{=40:pane_title}]" +set-option -g window-status-format "#I#{?window_zoomed_flag, ,}#F#{?window_flags,, }#{?window_zoomed_flag, ,}#{=20:pane_title}" + +set-option -g pane-active-border-fg colour247 +set-option -g pane-border-fg colour235 +set-option -g status-bg colour7 +set-option -g status-fg colour16 +set-option -g status-left-bg colour4 +set-option -g status-left-fg colour15 +set-option -g window-status-current-bg colour15 +set-option -g window-status-current-fg colour16 + +set-option -g update-environment "DBUS_SESSION_BUS_ADDRESS DISPLAY KRB5CCNAME \ + SESSION_MANAGER SSH_AGENT_PID SSH_ASKPASS SSH_AUTH_SOCK SSH_CONNECTION \ + WINDOWID XAUTHORITY SSH_TTY" + +bind-key w break-pane -d +bind-key l clear-history \; display "Pane history cleared." +bind-key C-f if-shell "test #{window_panes} -eq 1" last-window last-pane +bind-key N new-session +bind-key t new-window +bind-key z resize-pane -Z +bind-key C-r rotate-window -D +bind-key -n C-t run-shell "metamux new-shell-in-pane #{window_panes}" +bind-key n run-shell "metamux rotate-pane next" +bind-key p run-shell "metamux rotate-pane prev" +bind-key q run-shell "metamux pane-buster" +bind-key S run-shell "metamux join-hidden-pane -v" +bind-key u run-shell "metamux open-last-url-printed" +bind-key | run-shell "metamux join-hidden-pane -h" +bind-key f send-prefix +bind-key r source "$HOME/.tmux.conf" \; display "Configuration reloaded." + +# When the current window is split, Ctrl+Tab and Ctrl+Shift+Tab should rotate +# between the split windows. If there is only one pane in the current window, +# Ctrl+Tab and Ctrl+Shift+Tab will cycle between windows as though they were +# tabs in modern desktop UIs. +bind-key -n C-Tab if-shell "test #{window_panes} -eq 1" next-window "select-pane -t :.+" +bind-key -n C-S-Tab if-shell "test #{window_panes} -eq 1" previous-window "select-pane -t :.-" + +# Binding to mark and swap panes; if no pane is marked, the shortcut will mark +# the active pane, but if a pane is already marked, active pane will be swapped +# with the marked pane. +bind-key m if-shell 'test -z "$PANE_IS_MARKED"' \ + "select-pane -m; set-env PANE_IS_MARKED 1" \ + "swap-pane; select-pane -M; set-env -u PANE_IS_MARKED" diff --git a/regress/conf/ad21dbb0893240563ddfdd954b9903a1.conf b/regress/conf/ad21dbb0893240563ddfdd954b9903a1.conf new file mode 100644 index 00000000..27d8f310 --- /dev/null +++ b/regress/conf/ad21dbb0893240563ddfdd954b9903a1.conf @@ -0,0 +1,580 @@ +# Time-stamp: <2018-05-31 17:10:05 kmodi> +# https://github.com/tmux/tmux +# Hi-lock: (("\\(^\\s< \\**\\)\\(\\* *.*\\)" (1 'org-hide prepend) (2 '(:inherit org-level-1 :height 1.3 :weight bold :overline t :underline t) prepend))) +# Hi-Lock: end + +# Running tmux built from master branch on tcsh in uxterm +# tmux version 2.5-RC+ dev + +# Contents: +# +# PREFIX +# Source config +# Pane Management +# Window <-join/split-> Pane +# Select Panes +# Resize Panes +# Dynamic Split +# Window Management +# Window Navigation +# Swap Windows +# Split Window +# Layout +# Session Management +# Mouse +# Drag pane border to resize +# Left click on pane +# Middle click on pane +# Right click on pane +# Wheel scroll in pane +# Wheel scroll in pane WHILE in copy-mode +# Left click on status +# Middle click on status +# Other mouse settings +# Window Title +# Status Bar +# Left Status +# Right Status +# Pane Status +# Colors +# Status Bar Colors +# Message Colors +# Window Status Colors +# Pane Colors +# Mode Info Colors +# Activity +# Command Prompt +# Audible and Visual Bells +# Copy & Paste +# Synchronize commands to panes/windows/sessions +# Terminal Setting +# Other Options +# Server Options +# Session Options +# Window Options +# Notes + +# * PREFIX +set -g prefix C-z +unbind C-b # unbind the default binding to send prefix key to the application +# Often you'll run a tmux inside another tmux and need a command sequence to +# send things to the inner session. With below binding that can be accomplished +# using "PREFIX Z <command>" +bind Z send-prefix + +# * Source config +unbind r # unbind default binding to force redraw of attached client +bind r source-file ~/.tmux.conf \; display "Finished sourcing ~/.tmux.conf ." + +# * Pane Management + +set -g pane-base-index 1 # start pane indices at 1 +set -g main-pane-width 100 # used by selectl main-vertical +bind z resize-pane -Z # zoom/unzoom the current pane +# If the window has >1 panes kill them without confirming. But confirm before kill +# the last pane (along with its window) in a window +bind x if "tmux display -p \"#{window_panes}\" | grep ^1\$" \ + "confirm-before -p \"Kill the only pane in window? It will kill this window too! (y/n)\" kill-pane" \ + "kill-pane" +bind C clear-history \; display "Cleared history of the current pane." +unbind C-p +bind C-p run -b "tmux display -p -F '#{pane_current_path}' | xclip -i -sel pri" \; display "Copied current path '#{pane_current_path}' to the primary selection." + +# Hooks need tmux 2.3+ +# set-hook -g -u after-kill-pane # Remove after hook for kill-pane +set-hook -g after-kill-pane "selectl main-vertical" +# If -g options is used when setting the hook, it has to be used when +# removing (-u option) the hook too. + +# ** Window <-join/split-> Pane +# Join a pane *from* a different window (of same or different session) into the CURRENT window +# Binding mnemonic: F for (F)etch/pull (as in git) from a different window +bind F command-prompt -p "Join pane from [sess:]win#[.pane#] (ex: kmodi:3.1) into current window:" "join-pane -s '%%'" +# Join CURRENT pane *to* a different window +# Binding mnemonic: P for (P)ush (as in git) to a different window +bind P command-prompt -p "Send CURRENT pane to [sess:]win# (ex: kmodi:3):" "join-pane -t '%%'" +# PREFIX ! : break-pane, convert the current pane to a window + +# ** Select Panes +bind o select-pane -t :.+ # cycle to the next pane number +bind O select-pane -t :.- # cycle to the previous pane number +# PREFIX ; : last-pane or select-pane -l, switch to the last active pane +# PREFIX ← : select-pane -L, switch to the pane on the left +# PREFIX → : select-pane -R, switch to the pane on the right +# PREFIX ↑ : select-pane -U, switch to the pane on the top +# PREFIX ↓ : select-pane -D, switch to the pane on the bottom +# PREFIX { : swap-pane -U, swap current pane with the pane above (not literally above) +# PREFIX } : swap-pane -D, swap current pane with the pane below (not literally below) + +# ** Resize Panes +bind -r h resize-pane -L 2 +bind -r C-h resize-pane -L 2 +bind -r j resize-pane -D 2 +bind -r C-j resize-pane -D 2 +bind -r k resize-pane -U 2 +bind -r C-k resize-pane -U 2 +unbind l # unbind default binding for `last-window` +bind -r l resize-pane -R 2 +bind -r C-l resize-pane -R 2 + +# ** Dynamic Split +# Key-chaining example, analogous to prefix maps in emacs +bind / switch-client -Tlauncher +# Run below -Tlauncher commands using "PREFIX / <binding>" +# Open calendar in a split window "PREFIX / c" +# FIXME: Below does not work; cal pane quits as soon as it launches (before "&& sleep .." +# was added). To make better of the situation, I now auto-close that pane after 3 seconds. +# bind -Tlauncher c split-window -h 'cal && sleep 3' +bind -Tlauncher c run "/home/kmodi/scripts/tcsh/tmux/dynamic_split.csh 'cal && sleep 3'" +# Start emacsclient in terminal mode in a split window "PREFIX / e" +# Use the emacs binding "C-x 5 0" to quit from that pane gracefully. +bind -Tlauncher e run "/home/kmodi/scripts/tcsh/tmux/dynamic_split.csh 'emacsclient -a \"\" -t'" +# Open man page "PREFIX / m" +# PREFIX / m will bring up the tmux command prompt. Enter the command for which +# you want to see the man page, example: ls. That man page will open in a split +# pane. When you are done reviewing the man page, hit q and the split pane +# closes by itself. Beautiful! +bind -Tlauncher m command-prompt -p "man" "run \"/home/kmodi/scripts/tcsh/tmux/dynamic_split.csh 'man %1'\"" +# Open python interpreter in a split window for quick calculations "PREFIX / p" +# Ctrl-D in python quits python and thus closes the split window too. +bind -Tlauncher p run "/home/kmodi/scripts/tcsh/tmux/dynamic_split.csh 'ipython --profile=default --no-confirm-exit'" +# PREFIX Up, Down, Right, Left : Move cursor from one pane to another +# PREFIX Space : Cycle through different pane layouts +# PREFIX C-o : rotate-window, rotate panes in the current window + +# * Window Management +set -g base-index 1 # start window indices at 1 +# automatically renumber the windows +# http://unix.stackexchange.com/questions/21742/renumbering-windows-in-tmux +set -g renumber-windows on + +bind C-f command-prompt -p "New window:" "new-window -c '#{pane_current_path}' -n %1" +bind C-r command-prompt -p "New name for this window:" "rename-window '%%'" +unbind L # unbind default binding for `switch-client -l` +bind L list-windows -F '#{window_index}:#{window_name}: #{?pane_dead, (dead), (not dead)}' +unbind & # unbind default binding for `kill-window` +bind C-c confirm-before -p "Kill this window? (y/n)" kill-window +# Move the current window to another window index in the same or any other session +bind m command-prompt -p "Move window to sess or sess:win# or win# (ex: kmodi or kmodi:3 or 2(of current session)):" "move-window -t '%%'" +# Move or bring a window from a different session to the current one +bind M command-prompt -p "Move the window from sess:win# (ex: kmodi:3):" "move-window -s '%%'" + +# ** Window Navigation +bind C-z last-window # switch to last active window +# Allow repeats for next/previous-window +bind -r p previous-window +bind -r n next-window +# switch to another window by name +bind W split-window "tmux lsw | peco --initial-index `tmux lsw | awk '/active.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux select-window -t" +# PREFIX <N> : switches to window with index=N + +# ** Swap Windows +bind N move-window -r # renumber the windows +unbind , # unbind default binding for `rename-window` +bind -r , swap-window -t -1 # move window one position to the left +bind -r < swap-window -t -1 # move window one position to the left +unbind . # unbind default binding to move window to user provided index +bind -r . swap-window -t +1 # move window one position to the right +bind -r > swap-window -t +1 # move window one position to the right +unbind t # unbind default binding to show time +bind t swap-window -t 1 # swap the current window's position with window # 1, move it to the top + +# ** Split Window +unbind & # unbind default binding for `split-window -h` +bind - split-window -v -c '#{pane_current_path}' # vertical split +bind _ split-window -v -c '#{pane_current_path}' -f # full vertical split (v2.3+) +bind \ split-window -h -c '#{pane_current_path}' # horizontal split +bind | split-window -h -c '#{pane_current_path}' -f # full horizontal split (v2.3+) +# https://www.reddit.com/r/tmux/comments/3paqoi/tmux_21_has_been_released/cw5wy00 +bind w switch-client -Tsplit_wind +bind -Tsplit_wind v split-window -v -c '#{pane_current_path}' +bind -Tsplit_wind V split-window -v -c '#{pane_current_path}'\; swap-pane -U +bind -Tsplit_wind h split-window -h -c '#{pane_current_path}' +bind -Tsplit_wind H split-window -h -c '#{pane_current_path}'\; swap-pane -U + +# ** Layout +bind Space next-layout +bind C-Space select-layout -o # undo only the last layout change #v2.1 + +# * Session Management +bind C-t command-prompt -p "New name for this session:" "rename-session '%%'" +bind b switch-client -l # switch to previously selected session +# switch to another session by name +bind S split-window "tmux ls | peco --initial-index `tmux ls | awk '/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux switch-client -t" +# switch to ANY window in ANY session by name +bind s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION tmux lsw -F 'SESSION:#{window_name}' -t SESSION | peco --initial-index `tmux ls | cut -d: -f1 | xargs -I SESSION tmux lsw -F '___#{session_attached}#{window_active}___' -t SESSION | awk '/___11___/ {print NR-1}'` | xargs tmux switch-client -t" +# tmux kill-session -t NAME/SESSIONNUMBER # Kill session + +# * Mouse +# setw -g mode-mouse on # incompatible in tmux 2.1+ +set -g mouse on + +# ** Drag pane border to resize +# set -g mouse-resize-pane off # incompatible in tmux 2.1+ +bind -T root MouseDrag1Border resize-pane -M # default +# unbind -T root MouseDrag1Border # disable drag pane border to resize + +bind -T root MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= "#{pane_in_mode}" "copy-mode -M" "send-keys -M"' 'copy-mode -M' # default + +# ** Left click on pane +# set -g mouse-select-pane on # incompatible in tmux 2.1+ +# Left click on a pane selects it +# bind -T root MouseDown1Pane select-pane -t=\; send-keys -M # default +bind -T root MouseDown1Pane select-pane -t= + +# Sun Feb 19 11:31:34 EST 2017 - kmodi +# Below break in tmux 2.4 +# # Fri Aug 26 18:35:21 EDT 2016 - kmodi +# # FIXME Need to remember why I unbound the below 2 bindings +# unbind -temacs-copy MouseDown1Pane +# unbind -temacs-copy MouseUp1Pane +# # + +# https://groups.google.com/forum/#!topic/tmux-users/mHhdx7Au0Ds +# Fri Aug 26 18:30:15 EDT 2016 - kmodi +# Do not do the below!! That will update the primary selection with the top-most +# tmux buffer each time you left click on a pane. +# bind -T root MouseUp1Pane run -b "tmux show-buffer | xclip -i -sel pri" +# + +# Left click in the pane *followed after a region selection* copies that to the +# secondary selection +bind -T root MouseUp1Pane run -b "tmux show-buffer | xclip -i -sel sec" +# Fri Aug 26 19:03:57 EDT 2016 - kmodi +# FIXME: As of today it needs to be figured out how to best paste the content +# from secondary selection + +# ** Middle click on pane +# Middle click in a pane to paste from the primary selection +bind -T root MouseDown2Pane run -b "xclip -o -sel pri | tmux load-buffer - && tmux paste-buffer -s ' '" + +# ** Right click on pane +# Right click on a pane selects and marks it *if not in copy-mode*; else +# passes on the mode keys +# bind -T root MouseDown3Pane select-pane -t= -m # default +bind -T root MouseDown3Pane if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t= -m' + +# Sun Feb 19 11:32:00 EST 2017 - kmodi +# Below breaks in tmux 2.4 +# # Right click *release* on a pane *in copy-mode* quits copy-mode +# bind -temacs-copy MouseUp3Pane cancel + +# ** Wheel scroll in pane +unbind -T root WheelUpPane +unbind -T root WheelDownPane +# Do mouse wheel-up to enter copy mode and do page-up +# https://groups.google.com/d/msg/tmux-users/XTrSVUR15Zk/3iyJLMyQ7PwJ +# Below binding did not work +# bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'if -Ft= "#{pane_in_mode}" "copy-mode -u" "send-keys -M"' 'copy-mode -u' +# Below works and allows the WheelUpPane binding in emacs-copy table to be effective +bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= "#{pane_in_mode}" "send-keys -M" "copy-mode -u"' +# |---------------------+-----------------------------------------+--------------------------------| +# | using mouse? AND .. | #{pane_in_mode} (already in copy-mode?) | action | +# |---------------------+-----------------------------------------+--------------------------------| +# | Yes | Don't care | Send the mode keys | +# | No | Yes | Send the mode keys | +# | No | No | Enable copy-mode and do PageUp | +# |---------------------+-----------------------------------------+--------------------------------| + +# *** Wheel scroll in pane WHILE in copy-mode +# Sun Feb 19 11:32:16 EST 2017 - kmodi +# Below breaks in tmux 2.4 +# # Once in copy-mode, mouse wheel scrolls scrolls by half pages +# bind -temacs-copy WheelUpPane halfpage-up +# bind -temacs-copy WheelDownPane halfpage-down + +# ** Left click on status +# set -g mouse-select-window on # incompatible in tmux 2.1+ +# Left click on a window name in status bar to select it +bind -T root MouseDown1Status select-window -t= # default + +# ** Middle click on status +# Middle click on a window name in status bar to kill it +bind -T root MouseDown2Status kill-window + +# ** Other mouse settings +# The special token ‘{mouse}’ or ‘=’ may be used as target-window or target-pane in +# commands bound to mouse key bindings. Example: -t = + +# * Window Title +set -g set-titles on +set -g set-titles-string '#h :: #S:W#I(#W).P#P' + +# * Status Bar +set -g status-interval 5 # default = 15 seconds +set -g status-justify centre + +# ** Left Status +set -g status-left-length 20 +# Change the left status when prefix is pressed. +# https://www.reddit.com/r/tmux/comments/5cm2ca/post_you_favourite_tmux_tricks_here/d9ziuy9/ +set -g status-left "#{?client_prefix,#[fg=yellow]prefix pressed ..,[#S]}" + +# ** Right Status +set -g status-right-length 20 +set -g status-right "%l:%M %b %d %a " + +# ** Pane Status +setw -g pane-border-status "bottom" +setw -g pane-border-format " #P #T " + +# # tmux-powerline +# # https://github.com/erikw/tmux-powerline +# set -g status-left-length 30 +# set -g status-right-length 30 +# set -g status-left "#(~/usr_local/scripts/tmux-powerline/powerline.sh left)" +# set -g status-right "#(~/usr_local/scripts/tmux-powerline/powerline.sh right)" + +# * Colors + +# ** Status Bar Colors +set -g status-style fg=colour246,bg=colour233 # default for whole status line +set -g status-left-style fg=white,bold,bg=colour233 +set -g status-right-style fg=colour75,none,bg=colour233 + +# ** Message Colors +set -g message-style fg=colour2,bold,bg=default + +# ** Window Status Colors +setw -g window-status-style default # default for all window statuses +setw -g window-status-last-style fg=default,bg=colour235 +setw -g window-status-current-style fg=white,bold,bg=colour63 +setw -g window-status-bell-style default +setw -g window-status-activity-style fg=white,none,bg=colour196 +# setw -g window-status-content-style fg=black,none,bg=green # incompatible with tmux 2.0+ + +# ** Pane Colors +setw -g pane-active-border-style fg=colour63,bg=default +setw -g pane-border-style fg=colour235,bg=default +setw -g window-active-style 'bg=#330000' # bg color of active pane +setw -g window-style 'bg=black' # bg color of inactive pane(s) + +# ** Mode Info Colors +# Color of display shown on top-right in copy-mode, highlighting +setw -g mode-style fg=black,bg=colour244 + +# * Activity +# Notify when a window has activity +# This quick snippet will have tmux notify you in the status area when a +# window has activity: +setw -g monitor-activity on +set -g visual-activity off # Display message telling that an activity happened (on/off) +# It lets me know that there is activity in a non-active window +# To try this, enter `sleep 10 && echo “Hi”` in a window and switch to +# another window. + +# # Notify when a window has a content alert +# setw -g monitor-content "--[A-Za-z][A-Za-z]sim Done--" # This string appears when a sim finishes, alert then # incompatible with tmux 2.0+ +# # setw -g monitor-content "" # Disable monitor-content +# set -g visual-content on # Display message telling that a content alert was triggered (on/off) # incompatible with tmux 2.0+ + +# * Command Prompt +# Move focus to command prompt. tmux commands can be entered there directly +# without using the `tmux` prefix and it also supports auto-complete. +bind C-x command-prompt # default command-prompt binding "PREFIX :" also works + +# * Audible and Visual Bells +set -g bell-action any +set -g bell-on-alert off +set -g visual-bell on + +# * Copy & Paste +set -g set-clipboard off # default is on + +# Copy tmux buffer to primary and clipboard selections +# run -b runs a shell command in background +# http://grota.github.io/blog/2012/05/08/tmux-clipboard-integration/ +bind C-w run -b "tmux show-buffer | xclip -i -sel pri && tmux show-buffer | xclip -i -sel cli" +# Fri Aug 26 18:41:30 EDT 2016 - kmodi +# Below binding was suggested by Nicholas Marriott +# But the my older binding works fine so I am commenting out below for now. +# bind C-w run "tmux saveb - | xclip -i -sel pri; tmux saveb - | xclip -i -sel cli" +# Paste into tmux; also replace LF characters with +# space as separator characters (-s) when pasting. +# Yank from primary +bind C-y run -b "xclip -o -sel pri | tmux load-buffer - && tmux paste-buffer -s ' '" +# Yank from clipboard +bind M-y run -b "xclip -o -sel cli | tmux load-buffer - && tmux paste-buffer -s ' '" +# Open the file/dir path that was copied by selection in existing emacs client +# Usage: Highlight a file name in ls output and press "PREFIX e" +bind e run -b "tmux show-buffer | xclip -i -sel pri; (emacsclient -a '' `tmux display -p '#{pane_current_path}'`/`xclip -o -sel pri `&)" + +# * Synchronize commands to panes/windows/sessions +# Send the same command to all panes in the same window +bind C-a command-prompt -p "Command to all panes in this window:" \ + "run \"tmux list-panes -F '##{pane_index}' | xargs -I PANE \ + tmux send-keys -t PANE '%1' Enter\"" +# Alternative to using the above "C-a" binding is to enable pane synchronization, +# type the command you want to execute in all panes in the same window and disable +# pane synchronization +# Also turn the pane borders red while pane synchronization is enabled. +# - https://www.reddit.com/r/tmux/comments/5cm2ca/post_you_favourite_tmux_tricks_here/d9y6jzu/ +bind C-s if -F '#{pane_synchronized}' \ + 'setw synchronize-panes off; \ + setw pane-active-border-style fg=colour63,bg=default; \ + setw pane-border-format " #P #T "' \ + 'setw synchronize-panes on; \ + setw pane-active-border-style fg=red; \ + setw pane-border-format " #P - Pane Synchronization ON "' +# So it would be: C-s <type the command RET> C-s + +# https://scripter.co/command-to-every-pane-window-session-in-tmux/ +# Send the same command to all panes/windows in the current session +bind C-e command-prompt -p "Command:" \ + "run \"tmux list-panes -s -F '##{session_name}:##{window_index}.##{pane_index}' \ + | xargs -I PANE tmux send-keys -t PANE '%1' Enter\"" + +# Send the same command to all panes/windows/sessions +bind E command-prompt -p "Command:" \ + "run \"tmux list-panes -a -F '##{session_name}:##{window_index}.##{pane_index}' \ + | xargs -I PANE tmux send-keys -t PANE '%1' Enter\"" + +# * Terminal Setting + +# From `man tmux', about `default-terminal' +# Set the default terminal for new windows created in this session - the default +# value of the TERM environment variable. For tmux to work correctly, this must +# be set to ‘screen’, ‘tmux’ or a derivative of them. +# set -g default-terminal "screen" +set -g default-terminal "screen-256color" +# Mon May 22 11:43:56 EDT 2017 - kmodi +# Blinking text (useful to show broken symlinks in ls) does not work when using tmux-24bits. +# set -g default-terminal "tmux-24bits" +# tmux-24bits is a custom terminfo profile created using the steps explained +# on https://github.com/ThomasAdam/tmux/blob/master/FAQ to support italics and +# 256 colors. + +# Enable 24-bit color +# https://sunaku.github.io/tmux-24bit-color.html +set -ga terminal-overrides ",screen-256color:Tc" +# set -ga terminal-overrides ",tmux-24bits:Tc" + +# Thu May 31 17:10:04 EDT 2018 - kmodi +# TODO: Try the 24-bit emacs+tmux config for ST +# https://www.reddit.com/r/emacs/comments/8ndm2x/gnu_emacs_261_24bit_colors_suckless_st_terminal/dzwh4vv/ +# set -g default-terminal "tmux-256color" +# set -ga terminal-overrides ",*256col*:Tc" +# + +setw -g xterm-keys on + +# Uncomment below when using st (by suckless.org) +# set -g default-terminal "st-256color" +# # https://sunaku.github.io/tmux-24bit-color.html +# # st supports 24-bit color, so enable support for that in tmux +# set -ga terminal-overrides ",st-256color:Tc" +# setw -g xterm-keys off + +bind R refresh-client +# bind R refresh-client \; display "Refreshed the client." + +# * Other Options + +# ** Server Options +set -s escape-time 0 # Allows for faster key repetition + +# ** Session Options +# Set the default shell to /bin/sh. If the default is tcsh, doing a split-window takes a long +# time as my tcsh init is loaded first (which takes really long). +set -g default-shell /bin/sh +# If I am doing a new-window or split-window without a specified command, start the tcsh +# shell by default. +set -g default-command tcsh +set -g history-limit 100000 +set -g display-time 1000 # Duration of tmux display messages in milliseconds + +# ** Window Options +# When a smaller terminal connects to a tmux client, it shrinks to fit it. The +# clients attached with bigger displays see this constrained view. +# aggressive-resize makes it such that the window is only resized if the smaller +# client is actively looking at it. +setw -g aggressive-resize on +setw -g mode-keys emacs # Use emacs keybindings in copy mode +setw -g status-keys emacs + +# * Notes + +# |-------------------+------------| +# | tmux command | short form | +# |-------------------+------------| +# | set-option | set | +# | set-window-option | setw | +# | bind-key | bind | +# | unbind-key | unbind | +# | display-message | display | +# | run-shell | run | +# | if-shell | if | +# |-------------------+------------| + +# Colo'u'r table +# http://guns.github.io/xterm-color-table.vim/images/xterm-color-table.png + +# CHARACTER PAIR REPLACED WITH +# #(command) First line of command’s output +# #[attributes] Colour or attribute change +# #H Hostname of local host +# #I Current window index +# #P Current pane index +# #S Session name +# #T Current window title +# #W Current window name +# ## A literal ‘#’ + +# Variables used in time format +# Source: http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Commontimeformatvariables +# %y = year in numbers (2-digit) +# %Y = year in numbers (4-digit) +# %m = month in number (eg: 12) + # %B = full month name (eg: December)sho +# %b = short month name (eg: Dec) +# %d = day in numbers, with leading zeros (eg: 08) +# %e = day in numbers, no leading zeros (eg: 8) +# %A = full weekday name (eg: Sunday) +# %a = short weekday name (eg: Sun) +# %H = hours in 24-clock, with leading zeros +# %k = hours in 24-clock, no leading zeros +# %l = hours in 12-clock, with leading zeros +# %p = am/pm +# %T = time in 24-hour notation (%H:%M:%S) + +# PREFIX ? : list-keys, display key bindings + +# In command-prompt: show-options -g shows the global options +# In command-prompt: show-window-options -g shows the global windows options + +# How do I know which tmux version I am running? +# tmux -V + +# How to set bindings that don't need the prefix? +# bind -n .. or +# bind -T root .. + +# Changelog: https://github.com/tmux/tmux/blob/master/CHANGES + +# style colors: default, black, red, green, yellow, blue, magenta, cyan, white, +# colour0-colour255, hexdecimal RGB string '#ffffff' +# Use $SCRIPTS/bash/256-colors.sh to figure out the color number you want +# style attributes: none, bold/bright, dim, underscore, blink, reverse, hidden, +# or italics + +# https://www.reddit.com/r/tmux/comments/3paqoi/tmux_21_has_been_released/cw552qd + +# tmux buffers +# PREFIX # : List all paste buffers +# PREFIX - : Delete the most recently copied buffer of text +# PREFIX = : Choose which buffer to paste interactively from a list +# PREFIX ] : Paste the most recently copied buffer of text + +# How to start a temporary tmux server in addition to an existing running one? +# > tmux -L temp + +# In a shell environment in a terminal in tmux, the env var $TMUX will be +# defined to something like "/tmp/tmux-23273/default,31101,0". Outside tmux, +# $TMUX will be undefined. + +# Notation to address a specific pane +# SESSION_NAME:WINDOW_INDEX.PANE_NUMBER (Example: foo:2.1 i.e. Pane 1 in Window 2 of Session foo) + +# To print a message containing tmux variable values to stdout use '-p' option in display-message +# tmux display-message -p '#{session_name}:#{window_name}.#{pane_index}', or +# tmux display -p '#{session_name}:#{window_name}.#{pane_index}' diff --git a/regress/conf/b9f0ce1976ec62ec60dc5da7dd92c160.conf b/regress/conf/b9f0ce1976ec62ec60dc5da7dd92c160.conf new file mode 100644 index 00000000..0a878369 --- /dev/null +++ b/regress/conf/b9f0ce1976ec62ec60dc5da7dd92c160.conf @@ -0,0 +1,84 @@ +# none of these attempts worked, to bind keys, except sometimes during the sesssion. Oh well. +# I thought maybe that was because F1 is handled differently in a console than in X, but +# even just C-1 didnt work. Using just "a" or "x" as the key did, but not yet sure why not "C-". +#bind-key -T root C-1 attach-session -t$0 +#But this one works now, only picks the wrong one? Mbe need2understand what "$1" or $0 mean, better, +#but with the stub maybe this doesn't matter: +bind-key "`" switch-client -t$1 + +new-session #$0, stub, for keystroke convenience + +#$1 for root +new-session #a stub I guess, where keyboard convenience is concerned +new-window +send-keys -l pgup +send-keys Enter +send-keys -l "less /root/.tmux.conf &" +send-keys -l "echo; echo; echo Put something here for ssa or just run manly?" +send-keys Enter +new-window +new-window +new-window sul #for lcall, like man pages +send-keys -l "man tmux&" +send-keys Enter +select-window -t :=1 + +#$2 for om, so, can do C-b C-s 2 to get to the session, then C-b <#s> to get ~"tabs" +new-session sula ; send-keys -l q #0 +send-keys Enter Escape Escape +new-window sula ; send-keys -l q #1 +send-keys Enter Escape Escape +new-window sula ; send-keys -l q #2 +send-keys Enter Escape Enter Enter +new-window sula ; send-keys q #3, to start: +send-keys Enter Escape +# %%need a sleep here & .. ? +send-keys Enter Enter Enter Enter +new-window sula ; send-keys -l q #4 +send-keys Enter Escape Escape +new-window sula +new-window sula +new-window sula +new-window sula +new-window sula +select-window -t :=2 +select-window -t :=3 + +#$3 for email (mutt) +new-session sula +new-window sula ; send-keys mutt Enter +#nah, probly betr not?: +#send-keys -l z +#send-keys -l "thepassifdecide" +#send-keys Enter +new-window sula ; send-keys mutt Enter +send-keys -l "c!=sent" +send-keys Enter +new-window sula ; send-keys -l "cd mail/config; less mailsig.txt&" +send-keys Enter +send-keys "less macros&" +send-keys Enter +select-window -t :=1 + +#$4 for lacall-net: links etc +new-session suln +new-window suln +#send-keys -l "lkslfx" #; et; links ksl.com" +#send-keys asdafdfadfadfadfadf +#%%does opening links break subsequent cmds? With this Enter, the switch-client etc dont work: +#send-keys Enter +#send-keys Space Space Space +new-window suln +new-window suln +select-window -t :=1 +#send-keys Space Space Space + +#$5 for lacall-secnet, links?: +#new-session sulsn + +# then, where to start: +#%%need a sleep here, or ck a debug thing? +switch-client -t"$0" +send-keys -l "sleep 2" +send-keys Enter +switch-client -t$2 diff --git a/regress/conf/d0040b2e097f1e3d31d78eed6ce8d461.conf b/regress/conf/d0040b2e097f1e3d31d78eed6ce8d461.conf new file mode 100644 index 00000000..3ae7444a --- /dev/null +++ b/regress/conf/d0040b2e097f1e3d31d78eed6ce8d461.conf @@ -0,0 +1,108 @@ +# Put the status bar on top +#set -g status-position "top" + +# Basic colours, safer for dumb terminals. +#set -g status-style "bg=white,fg=black" +#set -g status-right-style "bg=green,fg=black" +#set -g window-status-current-style "bg=yellow,fg=black" +#set -g message-style "bg=white,fg=black" +#set -g window-status-activity-style "fg=blue" +#set -g window-status-bell-style "fg=red" + +## Moar colours! Not recommended if attaching from dumber terminals with 8 or 16 colours. +#set -g default-terminal "tmux-256color" +# A more compatible XTERM var. +set -g default-terminal "screen-256color" +set -g message-style "bg=#485548 fg=#ffffff" +set -g pane-border-style "fg=#424954" +set -g pane-active-border-style "fg=#ffffff" +set -g status-style "bg=#424954 fg=#ffffff" +set -g status-right-style "bg=#303338 fg=colour87" +set -g window-status-current-style "bg=#303338" +set -g window-status-last-style "bg=#364146" +set -g window-status-format ' #I:#W#[fg=colour201]#F ' +set -g window-status-current-format ' #[fg=colour226]#I#[fg=#ffffff]:#[fg=colour119]#W#[fg=colour202]#F ' +set -g window-status-separator "" + +# Uncomment and reload settings for sanity in a console with 8 colours. +#set -g status-style "bg=white,fg=black" +#set -g window-status-last-style "bg=white" + +# Might help when graphical characters used for vertical and horizontal lines are drawn as x and q. +#set-option -ga terminal-overrides ',*:enacs@:smacs@:rmacs@:acsc@' + +# Count panes starting from 1. +set -g base-index 1 + +# With this you set the window name in the status line. +# Beware of outrageous prompts, such as the default one in RHEL 7. +set -g set-titles on +# Let status right consists of only the pane title (removes date and time). +# Usually shows current path. +set -g status-right ' #T ' +# Increase the default length of 40. +set -g status-right-length 80 + +# Scroll up with the mouse. +set -g mouse + +# Clipboard integration, use this in tandem with the recommended xterm settings. +set -g set-clipboard on +# Pass through modifier keys, xterm style. You'll want this in vim. +set -g xterm-keys on +# Reduce time to wait for Escape key. You'll want this for neovim. +set-option escape-time 40 +# Leave ESC alone... +#set-option -s escape-time 0 + +# New-style mouse scroll (>2.1) +bind -n WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M +bind -n WheelDownPane select-pane -t= \; send-keys -M + +# This is for scrolling up with the terminal using keys, but has issues... +#set -ga terminal-overrides ',xterm*:smcup@:rmcup@' + +# 10x more history. +set -g history-limit 20000 + +# Swap the default Control-b with Control-s which usually stops the output in a shell. +unbind C-b +set-option -g terminal-overrides "xterm-rightclick:krightclick=^[[29~" +set -g prefix C-s +bind C-s send-prefix + +# For renumbering windows when you get gaps in numbering. +bind R \ + move-window -r\; \ + display-message "Windows reordered..." + +# My shortcuts. +#bind-key -n C-S-t new-window # Doesn't work :-/ +bind-key -n C-t new-window +bind-key -n C-PgUp prev +bind-key -n C-PgDn next +#bind-key -n C-S-PgUp swap-window -t -1 # Doesn't work :-/ +#bind-key -n C-S-PgDn swap-window -t +1 # Doesn't work :-/ +bind-key -n C-S-Left swap-window -t -1 +bind-key -n C-S-Right swap-window -t +1 +bind-key -n M-` select-window -t 0 +bind-key -n M-1 select-window -t 1 +bind-key -n M-2 select-window -t 2 +bind-key -n M-3 select-window -t 3 +bind-key -n M-4 select-window -t 4 +bind-key -n M-5 select-window -t 5 +bind-key -n M-6 select-window -t 6 +bind-key -n M-7 select-window -t 7 +bind-key -n M-8 select-window -t 8 +bind-key -n M-9 select-window -t 9 +bind-key -n M-0 select-window -t 10 + +# switch panes without prefix using Alt-arrow +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +# join pane from inputted window (horizontally or vertically) +#bind-key @ command-prompt -p "join pane from:" "join-pane -s ':%%' -h" +bind-key @ command-prompt -p "join pane from:" "join-pane -s ':%%' -v" diff --git a/regress/conf/d2e576f947e108eb9903679b65c81fbc.conf b/regress/conf/d2e576f947e108eb9903679b65c81fbc.conf new file mode 100644 index 00000000..392a69f0 --- /dev/null +++ b/regress/conf/d2e576f947e108eb9903679b65c81fbc.conf @@ -0,0 +1,198 @@ +### GENERAL + +set-option -g prefix C-a # Set prefix to <C-a> +bind a send-prefix # Send <C-a> with <C-a>a + +bind R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded" +bind -n M-R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded" + +set -g history-limit 10000 # lines to keep in hisoty +set-option -g display-panes-time 3000 # Timeout for pane-numbering in ms +bind -n M-q display-panes +set-option -sg escape-time 0 # speed up commands +set -g mouse on # enable mouse (tmux 2.1+) +set -g base-index 1 # start window numbering at 1 +set -g pane-base-index 1 # start pane numbering at 1 +set -g renumber-windows on # renumber windows automatically +setw -g automatic-rename on # rename window after process + +# Clear window name before renaming +bind , rename-window "" \; command-prompt "rename-window '%%'" + +#### APPEARANCE + +set -g default-terminal "screen-256color" # use 256 colors +setw -g aggressive-resize on # resize window to smallest client + +set -g pane-border-style fg=colour238 # border color for inactive panes +set -g pane-active-border-style fg=colour247 # border color for active panes + +# Status bar colors and format +setw -g window-status-format ' #[fg=#999999]#I #[fg=$666666]#W ' +setw -g window-status-current-format '#[fg=#ffffff] #I #W#[fg=#ffffff] ' +setw -g window-status-separator '#[fg=#292929]|#[fg=default]' +set -g status-bg default # background color for status bar +set -g status-position bottom # put status bar on top or bottom +set -g status-interval 2 # interval in s to update status +set -g status-justify left # horizontal alignment +set -g message-style fg=white,bg=black # appearance of status messages +set -g message-command-style fg=white # appearance of status message cmds + +# Left section of status bar +set -g status-left "" + +# Status bar visibility +set -g status off +bind -r -n M-t set status on +bind -r -n M-T set status off +bind t set status on +bind T set status off + +# Right section of status bar +if-shell 'uname | grep -qi Darwin' "set -g status-right \"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//') #[fg=cyan]#(~/bin/battery-osx) #(~/bin/mailstatus.sh) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#666666]%F #[fg=#bababa]%R\"" + +if-shell 'uname | grep -qi Linux' "set -g status-right \"#[fg=cyan]#(~/bin/battery-linux) #(~/bin/mailstatus.sh) #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=#666666]%F #[fg=#bababa]%R\"" + +# Scaling of status-bar sections +set -g status-right-length 40 + + +#### NAVIGATION + +# With C-a prefix +bind h select-pane -L # navigate left with <C-a>h +bind j select-pane -D # navigate down with <C-a>j +bind k select-pane -U # navigate up with <C-a>k +bind l select-pane -R # navigate right with <C-a>l +bind -r H resize-pane -L 5 # resize pane left with <C-a>H +bind -r J resize-pane -D 5 # resize pane down with <C-a>J +bind -r K resize-pane -U 5 # resize pane up with <C-a>K +bind -r L resize-pane -R 5 # resize pane right with <C-a>L + +# Navigate panes with Meta (alt) modifier + hjkl +bind -r -n M-h select-pane -L # navigate left with M-h +bind -r -n M-j select-pane -D # navigate down with M-j +bind -r -n M-k select-pane -U # navigate up with M-k +bind -r -n M-l select-pane -R # navigate right with M-l +bind -r -n M-H resize-pane -L 5 # resize pane left with M-H +bind -r -n M-J resize-pane -D 5 # resize pane down with M-J +bind -r -n M-K resize-pane -U 5 # resize pane up with M-K +bind -r -n M-L resize-pane -R 5 # resize pane right with M-L + +# Navigate windows with Meta (alt) modifier + number keys +bind -n M-1 select-window -t :=1 +bind -n M-2 select-window -t :=2 +bind -n M-3 select-window -t :=3 +bind -n M-4 select-window -t :=4 +bind -n M-5 select-window -t :=5 +bind -n M-6 select-window -t :=6 +bind -n M-7 select-window -t :=7 +bind -n M-8 select-window -t :=8 +bind -n M-9 select-window -t :=9 +bind -n M-0 select-window -t :=10 + +bind C-s last-window # go to last window with <C-a><C-s> +bind C-a last-pane # go to last pane with <C-a><C-a> +bind -n M-s last-window # go to last pane with M-s +bind -n M-a last-pane # go to last pane with M-a +bind -r n next-window # next window with <C-a>n +bind -r b previous-window # next window with <C-a>p + +bind -n -r M-n next-window # next window with <M-n> +bind -n -r M-b previous-window # previous window with <M-n> +#bind -n M-, run-shell "tmux list-panes -as -F \"##I.##P ##{pane_current_command} . #{pane_current_path} (#W)#F\" | fzf-tmux | cut -d \" \" -f 1 | xargs tmux select-pane -t" +bind -n M-, run-shell "tmux list-windows -F \"##I:##W\" | fzf-tmux | cut -d \":\" -f 1 | xargs tmux select-window -t" +bind -n M-. run-shell "tmux list-sessions -F \"##S\" | fzf-tmux | xargs tmux switch -t" + + +#### LAYOUT CHANGING BINDINGS + +# create panes in same directory +bind '"' split-window -c "#{pane_current_path}" +bind '%' split-window -h -c "#{pane_current_path}" + +bind -r z resize-pane -Z # toggle pane zoom with <C-a>z +bind -r y next-layout # cycle to next pane layout with <C-a>y +bind -r Y previous-layout # cycle to previous pane layout with <C-a>Y +bind -r r rotate-window # rotate panes with <C-a>r + +bind -n M-z resize-pane -Z # toggle pane zoom with <M-z> +bind -n -r M-y next-layout # cycle to next pane layout with <M-y> +bind -n -r M-Y previous-layout # cycle to previous pane layout with <M-Y> +bind -n -r M-r rotate-window # rotate panes with <M-r> + +bind -r Left swap-window -t -1 # Swap window left +bind -r Right swap-window -t +1 # Swap window right + +bind -r B swap-window -t -1 # Swap window left +bind -r N swap-window -t +1 # Swap window right +bind -n -r M-B swap-window -t -1 # Swap window left +bind -n -r M-N swap-window -t +1 # Swap window right + +#### CLIPBOARD + +# enable reattach-to-user-namespace which fixes pasteboard access and launchctl +bind Space copy-mode # enter copy mode with <C-a><Space> +bind -n M-u copy-mode # enter copy mode with M-u +bind -T copy-mode-vi M-u send -X halfpage-up # scroll up with M-u +bind -T copy-mode-vi M-d send -X halfpage-down # scroll down with M-d +bind -T copy-mode-vi v send -X begin-selection # start "visual" with v + +# Copy (yank) with y +if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i -sel clipboard"' +if-shell 'uname | grep -qi Darwin' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"' +if-shell 'uname | grep -qi Cygwin' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "cat > /dev/clipboard"' + +# Paste with C-a p or M-p +if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind p run "DISPLAY=:0 xclip -o | tmux load-buffer - ; tmux paste-buffer"' +if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' +if-shell 'uname | grep -qi Darwin' 'bind -n M-p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' +if-shell 'uname | grep -qi Cygwin' 'bind p run "cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer"' +if-shell 'uname | grep -qi Cygwin' 'bind -n M-p run "cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer"' + + +#### LAUNCH PROCESSES + +# use urlview to follow URLs in current pane +bind u capture-pane -J \; \ + save-buffer "/tmp/active_tmux_buffer" \; \ + delete-buffer \; \ + split-window -l 10 "urlview '/tmp/active_tmux_buffer' && rm /tmp/active_tmux_buffer" + +# Launch offlineimap in inactive splits +bind o split-window -p 25 '$SHELL -c "offlineimap -qf INBOX"' \; select-pane -l +bind O split-window -p 25 '$SHELL -c "offlineimap"' \; select-pane -l + +# Use nested bindings (<C-a>l) for grouping process launch bindings +bind -n C-M-v new-window -n vim "/usr/local/bin/vim" +bind -n C-M-w new-window -n weather \ + "curl 'wttr.in/?m'; echo -e '\nPress <enter> to quit'; read -n 1 -s" + +# Open new window and resize status accordingly (should be a hook instead) +bind Enter new-window -c "#{pane_current_path}" "$SHELL" +bind -n M-Enter new-window \ + "tmux set status-right-length `echo $(tput cols)/2|bc|tr -d '\n'`; zsh" + +# Use nested bindings (<C-a>m) for grouping music-control bindings +bind m switchc -Tmpd +bind -n M-m switchc -Tmpd +bind -Tmpd v new-window -n vimpc "vimpc" +bind -Tmpd p display "#(mpc toggle | tr '\n' ' ')" +bind -Tmpd s display "#(mpc stop | tr '\n' ' ')" +bind -Tmpd n display "#(mpc next | tr '\n' ' ')" +bind -Tmpd b display "#(mpc prev | tr '\n' ' ')" +bind -Tmpd r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')" +#bind -Tmpd r new-window -n mpc "mpc clear && mpc ls | mpc add && mpc shuffle && mpc play" + +bind -n C-M-p display "#(mpc toggle | tr '\n' ' ')" +bind -n C-M-s display "#(mpc stop | tr '\n' ' ')" +bind -n C-M-n display "#(mpc next | tr '\n' ' ')" +bind -n C-M-b display "#(mpc prev | tr '\n' ' ')" +#bind -n C-M-r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')" +bind -n C-M-a split-window -p 50 "source ~/code/fzf-mpd/fzf-mpd.zsh && fm" + +# fzf-locate from entire file system and insert result in current pane (Alt-`) +bind -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'" + +# Change to the previous pane, repeat the last command, change back +bind -n M-! last-pane \; send-keys C-p C-m \; last-pane diff --git a/regress/conf/d41d8cd98f00b204e9800998ecf8427e.conf b/regress/conf/d41d8cd98f00b204e9800998ecf8427e.conf new file mode 100644 index 00000000..79bcdb5d --- /dev/null +++ b/regress/conf/d41d8cd98f00b204e9800998ecf8427e.conf @@ -0,0 +1,148 @@ +set-option -g prefix C-a +unbind-key C-b +bind-key C-a send-prefix + +set-option -s set-clipboard on +set -sg escape-time 0 +set -g bell-action other +set -g lock-after-time 1800 +set -g lock-command 'tput civis && read -s -n1' +set -g history-limit 10000 +set -g default-terminal "screen-256color" +set -g pane-border-style fg=white,bg=default +set -g pane-active-border-style fg=red,bg=default +set -g repeat-time 100 +set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@:Tc" + +#set -g terminal-overrides '*88col*:colors=88,*256col*:colors=256,rxvt-uni*:Tc:XT:Ms=\E]52;%p1%s;%p2%s\007:Cc=\E]12;%p1%s\007:Cr=\E]12;green\007:Cs=\E]777;Cs;%p1%d\007' +set -g mouse on +set -g status-style bg=blue,fg=cyan + +set-hook -g alert-bell 'run -b "notify-send \"Bell in session #{session_name}:#{window_index}:#{window_name}\""' + +unbind-key / +unbind-key c +unbind-key d +unbind-key f +unbind-key i +unbind-key l +unbind-key n +unbind-key o +unbind-key p +unbind-key r +unbind-key s +unbind-key t +unbind-key w +unbind-key x +unbind-key | +unbind-key - +unbind-key A +unbind-key S +unbind-key . +unbind-key "'" +unbind-key '#' +unbind-key ' ' +unbind-key z +unbind-key ^z + +bind a send-prefix +bind c new-window -a -c '#{pane_current_path}' +bind d detach-client +bind "/" command-prompt "find-window '%%'" +bind i display-message +bind a last-window +bind n next-window +bind o select-pane -D +bind p previous-window +bind r respawn-window +bind s choose-tree -Z +bind t clock-mode +bind w choose-window +bind k confirm-before kill-pane +bind x set lock-command '/usr/bin/vlock' \; lock-client \; set lock-command 'tput civis && read -s -n1' +bind "|" split-window -v -c '#{pane_current_path}' +bind "-" split-window -h -c '#{pane_current_path}' +bind l command-prompt "rename-window '%%'" +bind S command-prompt "rename-session '%%'" +bind . display-panes +bind "'" command-prompt -p "SSH: " "new-window -n %1 'ssh %1'" +bind ' ' choose-window +bind z resize-pane -Z + +bind ^a last-window +bind ^c new-window -a -c '#{pane_current_path}' +bind ^d detach-client +bind ^i display-message +bind a last-window +bind ^n next-window +bind ^o select-pane -D +bind ^p previous-window +bind ^r respawn-window +bind ^s choose-session +bind ^t clock-mode +bind ^w choose-window +bind ^k confirm-before kill-pane +bind ^x lock-client +bind ^S command-prompt "rename-session '%%'" +bind ^z resize-pane -Z + +bind -n C-Left previous-window +bind -n C-Right next-window +bind -n C-s set status + +bind -r C-Left swapw -t:- +bind -r C-Right swapw -t:+ + +# Status stuff. +set -g status-left-style "fg=white, bg=magenta" +set -g status-left-length 30 +set -g status-left "#S " +set -g status-right-length 30 +set -g status-right-fg white +set -g status-right-bg blue +set -g status-right "#{?client_prefix,#[reverse][^a]#[noreverse],}[%a %d/%m %H:%M]" +set -g display-panes-time 4000 +set -g window-status-bell-style reverse + +#setw -g window-status-current-fg white +#setw -g window-status-current-bg colour34 +setw -g mode-keys vi + +setw -g window-status-separator "| " +#setw -g window-status-format "#[bg=blue]#I:#W:#{window_flags}#[bg=default]" +#setw -g window-status-current-format "#[fg=black,bg=green]#I:#W:#{window_flags}" + +setw -g window-status-format "#[bg=blue]#I:#W:#{?window_linked,+#{window_flags},#{window_flags} }#[bg=default]" +setw -g window-status-current-format "#[fg=black,bg=green]#I:#W:#{?window_linked,+#{window_flags},#{window_flags}}" + +set-window-option -g clock-mode-colour green + +# Sessions +new -d -sspecial +new -d -swork -d -nmutt 'exec neomutt' +neww -d +neww -d +neww -d +neww -d + +# FIXME -- the entire block below is required for taskwarrior. +#new -d -stask -ntask -x237 -y 79 +#selectl -ttask tiled +#set -ttask status off +#splitw -ttask:task +#splitw -ttask:task +#splitw -ttask:task +#splitw -ttask:task +#splitw -ttask:task +#selectl -ttask:task 4ada,237x79,0,0[237x67,0,0{156x67,0,0,5,80x67,157,0[80x27,157,0,19,80x22,157,28,20,80x16,157,51,21]},237x11,0,68,22] +#send -ttask:task.0 'cyclenext list' 'C-m' +#send -ttask:task.1 'clear ; tasksh' 'C-m' +#send -ttask:task.2 'cyclenext summary' 'C-m' +#send -ttask:task.3 'cyclenext burndown.daily' 'C-m' +#send -ttask:task.4 'cyclenext ghistory.monthly' 'C-m' +#selectp -ttask:task.1 +#linkw -stask:task -twork +#set -t task:task remain-on-exit on + +set -t work:irc remain-on-exit on +set -t work:mutt remain-on-exit on diff --git a/regress/conf/dfd579a114a8366b5a665c264e29c084.conf b/regress/conf/dfd579a114a8366b5a665c264e29c084.conf new file mode 100644 index 00000000..7ad12c95 --- /dev/null +++ b/regress/conf/dfd579a114a8366b5a665c264e29c084.conf @@ -0,0 +1,52 @@ +set -as terminal-overrides '\e\r\n\t\u12ab\U000012ab' +set -as terminal-overrides "\e\r\n\t\u12ab\U000012ab" + +# format #{abc #{def}} +# abc + +set -g status-left \ +"\u007c \ +abc" + +%if #{TMUX} +set -g status-bg red +%endif + +X=1 +Y=2 set -g status-bg blue; Z=3 set -g status-bg magenta + +set -g status-left "~/abcdef"$HOME # abcdef + +%if #{l:1} set -g status-bg red %endif + +%if #{l:0} +X=1 +%elif #{l:1} +Y=1 +%if #{l:0} +Y=2 +%else +Y=3 +%endif +%endif + +bind x display-message \"hello\" + +bind c neww -c ~ +bind ';' lsk + +set -g status-left "a""b" +set -g status-left ~ + +set -g status-left 'a $HOME b ~ c \e\e\e' +set -g status-left "a $HOME b ~ c \e\e\e" + +set -s command-alias[99] "foo=lsk;neww" +bind-key -n C-s if-shell 'true' 'display-message hello' + +set -g status-left-style \ +bg=red +set -g status-left \\\ +abc + +set -g status-left 'xyz' ; %if #{l:1} set -g status-bg red %endif ; bind x lsk diff --git a/regress/conf/e2661d67d0d45a8647fb95de76ec8174.conf b/regress/conf/e2661d67d0d45a8647fb95de76ec8174.conf new file mode 100644 index 00000000..79f46df1 --- /dev/null +++ b/regress/conf/e2661d67d0d45a8647fb95de76ec8174.conf @@ -0,0 +1,78 @@ +# Scott Rochford's tmux configuration +# +# change the prefix to the GNU screen default (avoids clash with page up in vi) +set -g prefix C-a +unbind-key C-b +bind-key C-a send-prefix +# toggle sending input to all panes +bind-key b set-window-option synchronize-panes +# alternative to ',' which doesn't pre-fill the prompt with the existing name +bind-key < command-prompt "rename-window '%%'" + +# Disabled all of these in favour of changing 'default-command' below. +#bind-key C-p pipe-pane -o 'cat >>~/tmux_logs/output.$(echo #I-#P-#W-#T | sed "s/[^[:alnum:].-]/_/g")' \; display-message 'Toggled logging' +# From http://unix.stackexchange.com/questions/5832/is-there-an-equivalent-of-gnu-screens-log-command-in-tmux +# bind-key H pipe-pane -o "exec cat >>$HOME/'#W-tmux.log'" \; display-message 'Toggled logging to $HOME/#W-tmux.log' +#bind-key H pipe-pane "exec cat >>$HOME/'#W-tmux.log'" \; display-message 'Started logging to $HOME/#W-tmux.log' +#bind-key h pipe-pane \; display-message 'Ended logging to $HOME/#W-tmux.log' + +#set -g utf8 on + +set-option -g history-limit 32768 + +# no longer available in 2.2 +#set-option -g mouse-select-pane on +#set-option -g mouse-select-window on +set-option -g mouse on + +# increase the amount of time status bar messages are displayed for (default 1000 I think) +set-option -g display-time 1500 +# unfortunately this seems to have no effect in putty :-( +set-option -g set-clipboard on +set-option -g default-command 'tmux pipe-pane -o "cat >>~/tmux_logs/output-`date +%Y%m%d-%H%M%S-$$`" ; /bin/ksh -l' +# +# allow yank into system clipboard +# from http://stackoverflow.com/questions/17255031/how-to-copy-from-tmux-running-in-putty-to-windows-clipbard +# +# for some reason this is wrapping at 80 cols, using save- instead of show- helps +# -b for background is needed because xclip continues to run to service the clipboard paste reqeusts until the +# clipboard buffer is replaced with some new contents +#bind C-y run-shell -b "tmux save-buffer - | DISPLAY=$(<~/.xdisplay) xclip -selection clipboard -in && tmux display-message 'xclipped successfully'" +bind C-y save-buffer ~/etc/clipboard.pipe +# +# this was just for testing, but interestingly for some reason tmux-show-buffer >/tmp/t never terminates, writing to a pipe works fine?? +#bind C-z run-shell "tmux show-buffer | cat >/tmp/t" +# move x clipboard into tmux paste buffer +#bind C-p run-shell -b "xclip -o -selection clipboard | tmux load-buffer - ; tmux paste-buffer" +bind C-p run-shell "DISPLAY=$(<~/.xdisplay) xclip -o -selection clipboard | tmux load-buffer - ; tmux paste-buffer" + +# switch to last-but-one window (like prefix-l but last, last) +# only works on tmux-2.4 + with Nicholas Marriott's patch from my feature request, unless it reached mainline.... +#bind k run-shell "tmux select-window -t $(tmux list-windows -F '#{session_stack}' | awk -F, '{print $3;exit}END{print $1}')" +bind k run-shell "tmux select-window -t $(echo #{session_stack} | awk -F, '{w=$1}NF>=3{w=$3;exit}END{print w}')" + +# switch to oldest window (for clean-up), not sure why brackets are required around (NF) here... +bind K run-shell "tmux select-window -t $(echo #{session_stack} | awk -F, '{print $(NF)}')" + +# prompt for hosts to connect to, open a new synchronized window with horizontally split panes for each host, supports brace expansion +bind N command-prompt -p hosts: 'run-shell -b "bash -c \"~/lbin/nw %% >/dev/null\""' + +# seems to cause unexpected resizes when focussing on putty :-( +#set-option mouse-resize-pane on + +#05:59 < Celti> annihilannic: I believe the #{pane_in_mode} format does what you want +#05:59 < Celti> put it in your statusline +#05:59 < Celti> annihilannic: No, my mistake, I should have read farther down, you want #{pane_synchronized} +# only works in tmux 2.0?, higher than 1.6.3 anyawy +set-option -g window-status-format ' #I:#W#F#{?pane_synchronized,S,}' +#set-option -g window-status-current-format ' #I:#W#{?pane_synchronized,[sync],}#F' +# to highlight in red when sync is on... not sure why I did this with set-window-option instead of set-option, perhaps +# both work? +set-window-option -g window-status-current-format "#{?pane_synchronized,#[bg=red],}#{?window_zoomed_flag,#[bg=yellow],} #I:#W#F#{?pane_synchronized,S,}" +# +# also only in 2.0? if I use this, don't need #F in window-status-*-format? - actually, nah, +# still useful for showing [Z]oomed, or - last active, etc. +set-option -g window-status-current-style bg=blue + +# Toggle input on a pane (from Thomas Sattler) +bind-key R if -F '#{pane_input_off}' "select-pane -e; select-pane -P fg=default" "select-pane -d; select-pane -P fg=yellow"
\ No newline at end of file diff --git a/regress/conf/ed08995f38b5a3079262a88d2563abe4.conf b/regress/conf/ed08995f38b5a3079262a88d2563abe4.conf new file mode 100644 index 00000000..a0fd1500 --- /dev/null +++ b/regress/conf/ed08995f38b5a3079262a88d2563abe4.conf @@ -0,0 +1,283 @@ +#---------------------------------------------------------------------------# +# .tmux.conf +# Helmut K. C. Tessarek, Last update 2018-10-16 +#---------------------------------------------------------------------------# + +#---------------------------------------------------------------------------# +# set prefix key to ctrl+a / ctrl-b is used in vi for going back one page +#---------------------------------------------------------------------------# +unbind C-b +set -g prefix C-a + +#---------------------------------------------------------------------------# +# send the prefix to client inside window (nested sessions) +#---------------------------------------------------------------------------# +bind-key a send-prefix + +#---------------------------------------------------------------------------# +# toggle last window like screen +#---------------------------------------------------------------------------# +bind-key C-a last-window + +#---------------------------------------------------------------------------# +# start window indexing at one instead of zero +#---------------------------------------------------------------------------# +#set -g base-index 1 + +#---------------------------------------------------------------------------# +# default terminal - we want 256 colors !!! +#---------------------------------------------------------------------------# +set -g default-terminal "screen-256color" + +#---------------------------------------------------------------------------# +# on-screen time for status messages in ms +#---------------------------------------------------------------------------# +set -g display-time 2000 + +#---------------------------------------------------------------------------# +# on-screen time for display-panes in ms +#---------------------------------------------------------------------------# +set -g display-panes-time 2000 + +#---------------------------------------------------------------------------# +# color for display pane indicator +#---------------------------------------------------------------------------# +set -g display-panes-colour "cyan" +#set -g display-panes-active-colour "#0087ff" +#set -g display-panes-active-colour "red" + +#---------------------------------------------------------------------------# +# open a man page in new window +#---------------------------------------------------------------------------# +unbind m +bind m command-prompt "split-window 'exec man %%'" + +#---------------------------------------------------------------------------# +# quick view of processes +#---------------------------------------------------------------------------# +#bind '~' split-window "exec htop" + +#---------------------------------------------------------------------------# +# scrollback buffer n lines +#---------------------------------------------------------------------------# +set -g history-limit 5000 + +#---------------------------------------------------------------------------# +# toggle status bar +#---------------------------------------------------------------------------# +unbind b +bind-key b set-option status + +#---------------------------------------------------------------------------# +# resize panes like vim +# feel free to change the "1" to however many lines you want to resize by, +# only one at a time can be slow +#---------------------------------------------------------------------------# +unbind < +unbind > +unbind - +unbind + +bind -r < resize-pane -L 1 +bind -r > resize-pane -R 1 +bind -r - resize-pane -D 1 +bind -r + resize-pane -U 1 + +#---------------------------------------------------------------------------# +# toggle mouse helpers +#---------------------------------------------------------------------------# +unbind Enter +unbind C-m +bind C-m set-option mouse \; display-message 'mouse -> #{?mouse,on,off}' + +#---------------------------------------------------------------------------# +# Reload config file +#---------------------------------------------------------------------------# +unbind R +bind-key R source-file ~/.tmux.conf \; display-message "Reloading configuration done" + +#---------------------------------------------------------------------------# +# start ssh session in new window +#---------------------------------------------------------------------------# +unbind S +bind-key S command-prompt "new-window -n %1 'ssh %1'" + +#---------------------------------------------------------------------------# +# start new session +#---------------------------------------------------------------------------# +unbind C +bind-key C command-prompt "new-session -s %1" + +#---------------------------------------------------------------------------# +# Keys to switch session +#---------------------------------------------------------------------------# +bind Q switchc -t0 +bind W switchc -t compile +bind E switchc -t config + +#---------------------------------------------------------------------------# +# break pane in background +#---------------------------------------------------------------------------# +unbind '@' +bind '@' break-pane -d + +#---------------------------------------------------------------------------# +# join pane with target window +#---------------------------------------------------------------------------# +unbind ^ +bind ^ command-prompt "join-pane -t %1" + +#---------------------------------------------------------------------------# +# move around panes with hjkl, as one would in vim after pressing ctrl-w +#---------------------------------------------------------------------------# +#bind h select-pane -L +#bind j select-pane -D +#bind k select-pane -U +#bind l select-pane -R + +#---------------------------------------------------------------------------# +# bind : to command-prompt like vim +# this is the default in tmux already +#---------------------------------------------------------------------------# +bind : command-prompt + +#---------------------------------------------------------------------------# +# Remain on exit +#---------------------------------------------------------------------------# +#setw -g remain-on-exit on + +#---------------------------------------------------------------------------# +# vi-style controls for copy mode +#---------------------------------------------------------------------------# +setw -g mode-keys vi + +#---------------------------------------------------------------------------# +# Make mouse useful in copy mode +#---------------------------------------------------------------------------# +#setw -g mode-mouse on + +#---------------------------------------------------------------------------# +# More straight forward key bindings for splitting +#---------------------------------------------------------------------------# +unbind % +unbind v +#bind | split-window -h +bind v split-window -h +unbind '"' +unbind h +#bind - split-window -v +bind h split-window -v + +#---------------------------------------------------------------------------# +# Synchronize panes +#---------------------------------------------------------------------------# +unbind y +bind y set-window-option synchronize-panes \; display-message 'synchronize-panes -> #{?synchronize-panes,on,off}' + +#---------------------------------------------------------------------------# +# Other key codes: Tab, BTab, Escape +#---------------------------------------------------------------------------# + +#---------------------------------------------------------------------------# +# Clock +#---------------------------------------------------------------------------# +setw -g clock-mode-colour green +setw -g clock-mode-style 24 + +#---------------------------------------------------------------------------# +# Terminal emulator window title +#---------------------------------------------------------------------------# +set -g set-titles on +set -g set-titles-string '#S:#I.#P #W' + +#---------------------------------------------------------------------------# +# Status Bar +#---------------------------------------------------------------------------# +set -g status-bg black +set -g status-fg white +set -g status-interval 1 +set -g status-left-length 30 +set -g status-left '#[fg=green]#h#[default] ' +#set -g status-right '#[fg=yellow]#(cut -d " " -f 1-4 /proc/loadavg)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default]' +#set -g status-right '#[fg=yellow,bold]%Y-%m-%d %H:%M#[default]' +set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M %Z#[default]' +#set -g status-justify center +#set -g status-keys vi + +set -g allow-rename off +setw -g automatic-rename on + +#---------------------------------------------------------------------------# +# Highlighting the active window in status bar +#---------------------------------------------------------------------------# +#setw -g window-status-current-bg red +set-option -g window-status-format "#I:#W#F#{?pane_synchronized,S,}" +set-window-option -g window-status-current-format "#{?pane_synchronized,#[bg=red],}#{?window_zoomed_flag,#[bg=colour130],}#I:#W#F#{?pane_synchronized,S,}" +set-option -g window-status-current-style bg=blue + +#---------------------------------------------------------------------------# +# global update environment +#---------------------------------------------------------------------------# +set -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TZ" + +#---------------------------------------------------------------------------# +# settings for AIX +# terminal overrides to enable colors +# set default terminal to vt100 or xterm (screen does not exist on AIX) +#---------------------------------------------------------------------------# +if-shell "uname|grep AIX" 'set -g terminal-overrides "xterm*:XT,xterm*:setab=\\E[4%p1%dm,xterm*:setaf=\\E[3%p1%dm"' +#if-shell "uname|grep AIX" "set -g default-terminal vt100" +if-shell "uname|grep AIX" "set -g default-terminal xterm" + +#---------------------------------------------------------------------------# +# settings for macOS +#---------------------------------------------------------------------------# +if-shell "uname|grep Darwin" 'set -g default-command "/bin/bash -l"' + +#---------------------------------------------------------------------------# +# Pane coloring +# set inactive/active window styles +#---------------------------------------------------------------------------# +set -g window-style "fg=colour247,bg=colour234" +set -g window-active-style "fg=colour250,bg=black" +set -g @TPCS "1" + +#---------------------------------------------------------------------------# +# pane border - different style / use cyan +#---------------------------------------------------------------------------# +#set -g pane-border-bg colour235 +#set -g pane-border-fg colour238 +#set -g pane-active-border-bg colour234 +#set -g pane-active-border-fg colour51 + +#---------------------------------------------------------------------------# +# toggle pane coloring on/off +#---------------------------------------------------------------------------# +unbind C-b +bind C-b if -F '#{@TPCS}' \ + 'set -g window-style "fg=default,bg=default" ; set -g window-active-style "fg=default,bg=default" ; set -g @TPCS "0"; display-message "Pane coloring -> off"' \ + 'set -g window-style "fg=colour247,bg=colour234" ; set -g window-active-style "fg=colour250,bg=black" ; set -g @TPCS "1"; display-message "Pane coloring -> on"' + +#---------------------------------------------------------------------------# +# List of plugins +#---------------------------------------------------------------------------# +set -g @plugin 'tmux-plugins/tpm' +#set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-logging' + +set -g @resurrect-capture-pane-contents 'on' +set -g @resurrect-save-bash-history 'on' + +set -g @logging-path $HOME +set -g @screen-capture-path $HOME +set -g @save-complete-history-path $HOME + +# Other examples: +# set -g @plugin 'github_username/plugin_name' +# set -g @plugin 'git@github.com/user/plugin' +# set -g @plugin 'git@bitbucket.com/user/plugin' + +#---------------------------------------------------------------------------# +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +#---------------------------------------------------------------------------# +run '~/.tmux/plugins/tpm/tpm' diff --git a/regress/control-client-sanity.sh b/regress/control-client-sanity.sh new file mode 100644 index 00000000..bf76b4d5 --- /dev/null +++ b/regress/control-client-sanity.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +OUT=$(mktemp) +trap "rm -f $TMP $OUT" 0 1 15 + +$TMUX -f/dev/null new -d -x200 -y200 || exit 1 +$TMUX -f/dev/null splitw || exit 1 +sleep 1 +cat <<EOF|$TMUX -C a >$TMP +selectp -t%0 +splitw +neww +splitw +selectp -t%0 +killp -t%1 +swapp -t%2 -s%3 +neww +splitw +splitw +selectl tiled +killw +EOF +sleep 1 +$TMUX has || exit 1 +$TMUX lsp -aF '#{pane_id} #{window_layout}' >$TMP || exit 1 +cat <<EOF|cmp -s $TMP - || exit 1 +%0 f5ab,200x200,0,0[200x50,0,0,0,200x149,0,51,3] +%3 f5ab,200x200,0,0[200x50,0,0,0,200x149,0,51,3] +%2 dcbd,200x200,0,0[200x100,0,0,2,200x99,0,101,4] +%4 dcbd,200x200,0,0[200x100,0,0,2,200x99,0,101,4] +EOF +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/control-client-size.sh b/regress/control-client-size.sh new file mode 100644 index 00000000..dc275e52 --- /dev/null +++ b/regress/control-client-size.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +# 947 +# size in control mode should change after refresh-client -C, and -x and -y +# should work without -d for control clients + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +OUT=$(mktemp) +trap "rm -f $TMP $OUT" 0 1 15 + +$TMUX -f/dev/null new -d || exit 1 +sleep 1 +cat <<EOF|$TMUX -C a >$TMP +ls -F':#{window_width} #{window_height}' +refresh -C 100,50 +EOF +grep ^: $TMP >$OUT +$TMUX ls -F':#{window_width} #{window_height}' >>$OUT +printf ":80 24\n:100 50\n"|cmp -s $OUT - || exit 1 +$TMUX kill-server 2>/dev/null + +$TMUX -f/dev/null new -d || exit 1 +sleep 1 +cat <<EOF|$TMUX -f/dev/null -C a >$TMP +ls -F':#{window_width} #{window_height}' +refresh -C 80,24 +EOF +grep ^: $TMP >$OUT +$TMUX ls -F':#{window_width} #{window_height}' >>$OUT +printf ":80 24\n:80 24\n"|cmp -s $OUT - || exit 1 +$TMUX kill-server 2>/dev/null + +cat <<EOF|$TMUX -f/dev/null -C new -x 100 -y 50 >$TMP +ls -F':#{window_width} #{window_height}' +refresh -C 80,24 +EOF +grep ^: $TMP >$OUT +$TMUX ls -F':#{window_width} #{window_height}' >>$OUT +printf ":100 50\n:80 24\n"|cmp -s $OUT - || exit 1 +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/cursor-test.txt b/regress/cursor-test.txt new file mode 100644 index 00000000..67ed52c8 --- /dev/null +++ b/regress/cursor-test.txt @@ -0,0 +1,6 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor +incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea +commodo consequat. Duis aute +irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat +nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia +deserunt mollit anim id est laborum. diff --git a/regress/cursor-test1.result b/regress/cursor-test1.result new file mode 100644 index 00000000..71b9a4b6 --- /dev/null +++ b/regress/cursor-test1.result @@ -0,0 +1,33 @@ +14 8 t +0 ud exercitation ullamco laboris nisi ut +1 aliquip ex ea +2 commodo consequat. Duis aute +3 irure dolor in reprehenderit in voluptat +4 e velit esse cillum dolore eu fugiat +5 nulla pariatur. Excepteur sint occaecat +6 cupidatat non proident, sunt in culpa qu +7 i officia +8 deserunt mollit anim id est laborum. +9 +4 6 t +0 cupidatat +1 non proide +2 nt, sunt i +3 n culpa qu +4 i officia +5 deserunt m +6 ollit anim +7 id est la +8 borum. +9 +14 8 t +0 incididunt ut labore et dolore magna aliqua. Ut en +1 im ad minim veniam, quis nostrud exercitation ulla +2 mco laboris nisi ut aliquip ex ea +3 commodo consequat. Duis aute +4 irure dolor in reprehenderit in voluptate velit es +5 se cillum dolore eu fugiat +6 nulla pariatur. Excepteur sint occaecat cupidatat +7 non proident, sunt in culpa qui officia +8 deserunt mollit anim id est laborum. +9 diff --git a/regress/cursor-test1.sh b/regress/cursor-test1.sh new file mode 100644 index 00000000..2dc20539 --- /dev/null +++ b/regress/cursor-test1.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -f/dev/null -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +$TMUX -f/dev/null new -d -x40 -y10 \ + "cat cursor-test.txt; printf '\e[9;15H'; cat" || exit 1 +$TMUX set -g window-size manual || exit 1 + +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x10 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x50 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP + +cmp -s $TMP cursor-test1.result || exit 1 + +$TMUX kill-server 2>/dev/null +exit 0 diff --git a/regress/cursor-test2.result b/regress/cursor-test2.result new file mode 100644 index 00000000..dc005d2b --- /dev/null +++ b/regress/cursor-test2.result @@ -0,0 +1,33 @@ +9 7 a +0 cupidatat +1 non proide +2 nt, sunt i +3 n culpa qu +4 i officia +5 deserunt m +6 ollit anim +7 id est la +8 borum. +9 +4 6 a +0 icia +1 deser +2 unt m +3 ollit +4 anim +5 id e +6 st la +7 borum +8 . +9 +29 8 a +0 incididunt ut labore et dolore magna aliqua. Ut en +1 im ad minim veniam, quis nostrud exercitation ulla +2 mco laboris nisi ut aliquip ex ea +3 commodo consequat. Duis aute +4 irure dolor in reprehenderit in voluptate velit es +5 se cillum dolore eu fugiat +6 nulla pariatur. Excepteur sint occaecat cupidatat +7 non proident, sunt in culpa qui officia +8 deserunt mollit anim id est laborum. +9 diff --git a/regress/cursor-test2.sh b/regress/cursor-test2.sh new file mode 100644 index 00000000..9791f567 --- /dev/null +++ b/regress/cursor-test2.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +$TMUX -f/dev/null new -d -x10 -y10 \ + "cat cursor-test.txt; printf '\e[8;10H'; cat" || exit 1 +$TMUX set -g window-size manual || exit 1 + +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x5 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x50 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP + +cmp -s $TMP cursor-test2.result || exit 1 + +$TMUX kill-server 2>/dev/null +exit 0 diff --git a/regress/cursor-test3.result b/regress/cursor-test3.result new file mode 100644 index 00000000..e72b1a9b --- /dev/null +++ b/regress/cursor-test3.result @@ -0,0 +1,9 @@ +6 1 b +0 abcdefa +1 bcdefab +3 1 b +0 fabcd +1 efab +6 1 b +0 abcdefa +1 bcdefab diff --git a/regress/cursor-test3.sh b/regress/cursor-test3.sh new file mode 100644 index 00000000..8bb4bd6f --- /dev/null +++ b/regress/cursor-test3.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +$TMUX -f/dev/null new -d -x7 -y2 \ + "printf 'abcdefabcdefab'; printf '\e[2;7H'; cat" || exit 1 +$TMUX set -g window-size manual || exit 1 + +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x5 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x7 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP + +cmp -s $TMP cursor-test3.result || exit 1 + +$TMUX kill-server 2>/dev/null +exit 0 diff --git a/regress/cursor-test4.result b/regress/cursor-test4.result new file mode 100644 index 00000000..db26e4fa --- /dev/null +++ b/regress/cursor-test4.result @@ -0,0 +1,16 @@ +0 1 +0 abcdef +1 +2 +0 1 +0 abcdef +1 +2 +0 1 +0 def +1 +2 +0 1 +0 abcdef +1 +2 diff --git a/regress/cursor-test4.sh b/regress/cursor-test4.sh new file mode 100644 index 00000000..2bf1bb0e --- /dev/null +++ b/regress/cursor-test4.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +$TMUX -f/dev/null new -d -x10 -y3 "printf 'abcdef\n'; cat" || exit 1 +$TMUX set -g window-size manual || exit 1 + +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x20 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x3 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP +$TMUX resizew -x10 || exit 1 +$TMUX display -pF '#{cursor_x} #{cursor_y} #{cursor_character}' >>$TMP +$TMUX capturep -p|awk '{print NR-1,$0}' >>$TMP + +cmp -s $TMP cursor-test4.result || exit 1 + +$TMUX kill-server 2>/dev/null +exit 0 diff --git a/regress/format-strings.sh b/regress/format-strings.sh new file mode 100644 index 00000000..726b46bc --- /dev/null +++ b/regress/format-strings.sh @@ -0,0 +1,183 @@ +#!/bin/sh + +# Tests of formats as described in tmux(1) FORMATS + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" + +# test_format $format $expected_result +test_format() +{ + fmt="$1" + exp="$2" + + out=$($TMUX display-message -p "$fmt") + + if [ "$out" != "$exp" ]; then + echo "Format test failed for '$fmt'." + echo "Expected: '$exp'" + echo "But got '$out'" + exit 1 + fi +} + +# test_conditional_with_pane_in_mode $format $exp1 $exp2 +# +# Tests the format string $format to yield $exp1 if #{pane_in_mode} is true and +# $exp2 when #{pane_in_mode} is false. +test_conditional_with_pane_in_mode() +{ + fmt="$1" + exp_true="$2" + exp_false="$3" + + $TMUX copy-mode # enter copy mode + test_format "$fmt" "$exp_true" + $TMUX send-keys -X cancel # leave copy mode + test_format "$fmt" "$exp_false" +} + +# test_conditional_with_session_name #format $exp_summer $exp_winter +# +# Tests the format string $format to yield $exp_summer if the session name is +# 'Summer' and $exp_winter if the session name is 'Winter'. +test_conditional_with_session_name() +{ + fmt="$1" + exp_summer="$2" + exp_winter="$3" + + $TMUX rename-session "Summer" + test_format "$fmt" "$exp_summer" + $TMUX rename-session "Winter" + test_format "$fmt" "$exp_winter" + $TMUX rename-session "Summer" # restore default +} + + +$TMUX kill-server 2>/dev/null +$TMUX -f/dev/null new-session -d || exit 1 +$TMUX rename-session "Summer" || exit 1 # used later in conditionals + +# Plain string without substitutions et al +test_format "abc xyz" "abc xyz" + +# Test basic escapes for "#", "{", "#{" "}", "#}", "," +test_format "##" "#" +test_format "#," "," +test_format "{" "{" +test_format "##{" "#{" +test_format "#}" "}" +test_format "###}" "#}" # not a "basic" one but interesting nevertheless + +# Simple expansion +test_format "#{pane_in_mode}" "0" + +# Simple conditionals +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,xyz}" "abc" "xyz" + +# Expansion in conditionals +test_conditional_with_pane_in_mode "#{?pane_in_mode,#{session_name},xyz}" "Summer" "xyz" + +# Basic escapes in conditionals +# First argument +test_conditional_with_pane_in_mode "#{?pane_in_mode,##,xyz}" "#" "xyz" +test_conditional_with_pane_in_mode "#{?pane_in_mode,#,,xyz}" "," "xyz" +test_conditional_with_pane_in_mode "#{?pane_in_mode,{,xyz}" "{" "xyz" +test_conditional_with_pane_in_mode "#{?pane_in_mode,##{,xyz}" "#{" "xyz" +test_conditional_with_pane_in_mode "#{?pane_in_mode,#},xyz}" "}" "xyz" +# not a "basic" one but interesting nevertheless +test_conditional_with_pane_in_mode "#{?pane_in_mode,###},xyz}" "#}" "xyz" +# Second argument +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,##}" "abc" "#" +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,#,}" "abc" "," +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,{}" "abc" "{" +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,##{}" "abc" "#{" +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,#}}" "abc" "}" +# not a "basic" one but interesting nevertheless +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,###}}" "abc" "#}" +# mixed +test_conditional_with_pane_in_mode "#{?pane_in_mode,{,#}}" "{" "}" +test_conditional_with_pane_in_mode "#{?pane_in_mode,#},{}" "}" "{" +test_conditional_with_pane_in_mode "#{?pane_in_mode,##{,###}}" "#{" "#}" +test_conditional_with_pane_in_mode "#{?pane_in_mode,###},##{}" "#}" "#{" + +# Conditionals split on the second comma (this is not documented) +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,xyz,bonus}" "abc" "xyz,bonus" + +# Curly brackets {...} do not capture a comma inside of conditionals as the +# conditional ends on the first '}' +test_conditional_with_pane_in_mode "#{?pane_in_mode,{abc,xyz},bonus}" "{abc,bonus}" "xyz,bonus}" + +# Substitutions '#{...}' capture the comma +# invalid format: #{abc,xyz} is not a known variable name. +#test_conditional_with_pane_in_mode "#{?pane_in_mode,#{abc,xyz},bonus}" "" "bonus" + +# Parenthesis (...) do not captura a comma +test_conditional_with_pane_in_mode "#{?pane_in_mode,(abc,xyz),bonus}" "(abc" "xyz),bonus" +test_conditional_with_pane_in_mode "#{?pane_in_mode,(abc#,xyz),bonus}" "(abc,xyz)" "bonus" + +# Brackets [...] do not captura a comma +test_conditional_with_pane_in_mode "#{?pane_in_mode,[abc,xyz],bonus}" "[abc" "xyz],bonus" +test_conditional_with_pane_in_mode "#{?pane_in_mode,[abc#,xyz],bonus}" "[abc,xyz]" "bonus" + + +# Escape comma inside of #(...) +# Note: #() commands are run asynchronous and are substituted with result of the +# *previous* run or a placeholder (like "<'echo ,' not ready") if the command +# has not been run before. The format is updated as soon as the command +# finishes. As we are printing the message only once it never gets updated +# and the displayed message is "<'echo ,' not ready>" +test_format "#{?pane_in_mode,#(echo #,),xyz}" "xyz" +test_conditional_with_pane_in_mode "#{?pane_in_mode,#(echo #,),xyz}" "<'echo ,' not ready>" "xyz" +# This caching does not work :-( +#$TMUX display-message -p "#(echo #,)" > /dev/null +#test_conditional_with_pane_in_mode "#{?pane_in_mode,#(echo #,),xyz}" "," "xyz" +#test_conditional_with_pane_in_mode "#{?pane_in_mode,#(echo #,),xyz}" "," "xyz" + +# invalid format: '#(' is not closed in the first argument of #{?,,}. +#test_conditional_with_pane_in_mode "#{?pane_in_mode,#(echo ,),xyz}" "" "),xyz" + +# Escape comma inside of #[...] +test_conditional_with_pane_in_mode "#{?pane_in_mode,#[fg=default#,bg=default]abc,xyz}" "#[fg=default,bg=default]abc" "xyz" +# invalid format: '#[' is not closed in the first argument of #{?,,} +#test_conditional_with_pane_in_mode "#{?pane_in_mode,#[fg=default,bg=default]abc,xyz}" "" "bg=default]abc,xyz" + +# Conditionals with comparison +test_conditional_with_session_name "#{?#{==:#{session_name},Summer},abc,xyz}" "abc" "xyz" +# Conditionals with comparison and escaped commas +$TMUX rename-session "," +test_format "#{?#{==:#,,#{session_name}},abc,xyz}" "abc" +$TMUX rename-session "Summer" # reset to default + +# Conditional in conditional +test_conditional_with_pane_in_mode "#{?pane_in_mode,#{?#{==:#{session_name},Summer},ABC,XYZ},xyz}" "ABC" "xyz" +test_conditional_with_session_name "#{?pane_in_mode,#{?#{==:#{session_name},Summer},ABC,XYZ},xyz}" "xyz" "xyz" + +test_conditional_with_pane_in_mode "#{?pane_in_mode,abc,#{?#{==:#{session_name},Summer},ABC,XYZ}}" "abc" "ABC" +test_conditional_with_session_name "#{?pane_in_mode,abc,#{?#{==:#{session_name},Summer},ABC,XYZ}}" "ABC" "XYZ" + +# Some fancy stackings +test_conditional_with_pane_in_mode "#{?#{==:#{?pane_in_mode,#{session_name},#(echo Spring)},Summer},abc,xyz}" "abc" "xyz" + + + +# Format test for the literal option +# Note: The behavior for #{l:...} with escapes is sometimes weird as #{l:...} +# respects the escapes. +test_format "#{l:#{}}" "#{}" +test_format "#{l:#{pane_in_mode}}" "#{pane_in_mode}" +test_format "#{l:#{?pane_in_mode,#{?#{==:#{session_name},Summer},ABC,XYZ},xyz}}" "#{?pane_in_mode,#{?#{==:#{session_name},Summer},ABC,XYZ},xyz}" + +# With escapes (which escape but are returned literally) +test_format "#{l:##{}" "##{" +test_format "#{l:#{#}}}" "#{#}}" + +# Invalid formats: +#test_format "#{l:#{}" "" +#test_format "#{l:#{#}}" "" + +exit 0 diff --git a/regress/has-session-return.sh b/regress/has-session-return.sh new file mode 100644 index 00000000..5cc30f05 --- /dev/null +++ b/regress/has-session-return.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# 971 +# has-session should return 1 on error + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +$TMUX -f/dev/null has -tfoo </dev/null 2>/dev/null && exit 1 +$TMUX -f/dev/null start\; has -tfoo </dev/null 2>/dev/null && exit 1 +$TMUX -f/dev/null new -d\; has -tfoo </dev/null 2>/dev/null && exit 1 +$TMUX -f/dev/null new -dsfoo\; has -tfoo </dev/null 2>/dev/null || exit 1 +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/if-shell-TERM.sh b/regress/if-shell-TERM.sh new file mode 100644 index 00000000..5967a58f --- /dev/null +++ b/regress/if-shell-TERM.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# 882 +# TERM should come from outside tmux for if-shell from the config file + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +cat <<EOF >$TMP +if '[ "\$TERM" = "xterm" ]' \ + 'set -g default-terminal "vt220"' \ + 'set -g default-terminal "ansi"' +EOF + +TERM=xterm $TMUX -f$TMP new -d "echo \"#\$TERM\" >>$TMP" || exit 1 +sleep 1 && [ "$(tail -1 $TMP)" = "#vt220" ] || exit 1 + +TERM=screen $TMUX -f$TMP new -d "echo \"#\$TERM\" >>$TMP" || exit 1 +sleep 1 && [ "$(tail -1 $TMP)" = "#ansi" ] || exit 1 + +$TMUX has 2>/dev/null && exit 1 + +exit 0 diff --git a/regress/if-shell-error.sh b/regress/if-shell-error.sh new file mode 100644 index 00000000..24dc578e --- /dev/null +++ b/regress/if-shell-error.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# 883 +# if-shell with an error should not core :-) + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +cat <<EOF >$TMP +if 'true' 'wibble wobble' +EOF + +$TMUX -f$TMP new -d || exit 1 +sleep 1 +E=$($TMUX display -p '#{pane_in_mode}') +$TMUX kill-server 2>/dev/null +[ "$E" = "1" ] || exit 1 + +exit 0 diff --git a/regress/if-shell-nested.sh b/regress/if-shell-nested.sh new file mode 100644 index 00000000..976c6738 --- /dev/null +++ b/regress/if-shell-nested.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# 882 +# tmux inside if-shell itself should work + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +cat <<EOF >$TMP +if '$TMUX run "true"' 'set -s @done yes' +EOF + +TERM=xterm $TMUX -f$TMP new -d "$TMUX show -vs @done >>$TMP" || exit 1 +sleep 1 && [ "$(tail -1 $TMP)" = "yes" ] || exit 1 + +$TMUX has 2>/dev/null && exit 1 + +exit 0 diff --git a/regress/kill-session-process-exit.sh b/regress/kill-session-process-exit.sh new file mode 100644 index 00000000..69ee27a2 --- /dev/null +++ b/regress/kill-session-process-exit.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# when we kill a session, processes running in it should be killed + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +$TMUX -f/dev/null new -d 'sleep 1000' || exit 1 +P=$($TMUX display -pt0:0.0 '#{pane_pid}') +$TMUX -f/dev/null new -d || exit 1 +sleep 1 +$TMUX kill-session -t0: +sleep 1 +kill -0 $P 2>/dev/null && exit 1 +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/new-session-base-index.sh b/regress/new-session-base-index.sh new file mode 100644 index 00000000..337037c3 --- /dev/null +++ b/regress/new-session-base-index.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# new session base-index + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +cat <<EOF >$TMP +set -g base-index 100 +new +set base-index 200 +neww +EOF + +$TMUX -f$TMP start +echo $($TMUX lsw -F'#{window_index}') >$TMP +(echo "100 200"|cmp -s - $TMP) || exit 1 +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/new-session-command.sh b/regress/new-session-command.sh new file mode 100644 index 00000000..02ba55d9 --- /dev/null +++ b/regress/new-session-command.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# new session command + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +cat <<EOF >$TMP +new sleep 101 +new -- sleep 102 +new "sleep 103" +EOF + +$TMUX -f$TMP start +[ $($TMUX ls|wc -l) -eq 3 ] || exit 1 +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/new-session-environment.sh b/regress/new-session-environment.sh new file mode 100644 index 00000000..d53f204e --- /dev/null +++ b/regress/new-session-environment.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +# new session environment + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +OUT=$(mktemp) +SCRIPT=$(mktemp) +trap "rm -f $TMP $OUT $SCRIPT" 0 1 15 + +cat <<EOF >$SCRIPT +( +echo TERM=\$TERM +echo PWD=\$(pwd) +echo PATH=\$PATH +echo SHELL=\$SHELL +echo TEST=\$TEST +) >$OUT +EOF + +cat <<EOF >$TMP +new -- /bin/sh $SCRIPT +EOF + +(cd /; env -i TERM=ansi TEST=test1 PATH=1 SHELL=/bin/sh \ + $TMUX -f$TMP start) || exit 1 +sleep 1 +(cat <<EOF|cmp -s - $OUT) || exit 1 +TERM=screen +PWD=/ +PATH=1 +SHELL=/bin/sh +TEST=test1 +EOF + +(cd /; env -i TERM=ansi TEST=test2 PATH=2 SHELL=/bin/sh \ + $TMUX -f$TMP new -d -- /bin/sh $SCRIPT) || exit 1 +sleep 1 +(cat <<EOF|cmp -s - $OUT) || exit 1 +TERM=screen +PWD=/ +PATH=2 +SHELL=/bin/sh +TEST=test2 +EOF + +(cd /; env -i TERM=ansi TEST=test3 PATH=3 SHELL=/bin/sh \ + $TMUX -f/dev/null new -d source $TMP) || exit 1 +sleep 1 +(cat <<EOF|cmp -s - $OUT) || exit 1 +TERM=screen +PWD=/ +PATH=2 +SHELL=/bin/sh +TEST=test2 +EOF + +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/new-session-no-client.sh b/regress/new-session-no-client.sh new file mode 100644 index 00000000..88c064cd --- /dev/null +++ b/regress/new-session-no-client.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# 869 +# new with no client (that is, from the config file) should imply -d and +# not attach + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +cat <<EOF >$TMP +new -stest +EOF + +$TMUX -f$TMP start || exit 1 +sleep 1 && $TMUX has -t=test: || exit 1 +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/new-session-size.sh b/regress/new-session-size.sh new file mode 100644 index 00000000..89fc580d --- /dev/null +++ b/regress/new-session-size.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# new-session without clients should be the right size + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +$TMUX -f/dev/null new -d </dev/null || exit 1 +sleep 1 +$TMUX ls -F "#{window_width} #{window_height}" >$TMP +printf "80 24\n"|cmp -s $TMP - || exit 1 +$TMUX kill-server 2>/dev/null + +$TMUX -f/dev/null new -d -x 100 -y 50 </dev/null || exit 1 +sleep 1 +$TMUX ls -F "#{window_width} #{window_height}" >$TMP +printf "100 50\n"|cmp -s $TMP - || exit 1 +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/new-window-command.sh b/regress/new-window-command.sh new file mode 100644 index 00000000..176bffb5 --- /dev/null +++ b/regress/new-window-command.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# new session command + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +TMP=$(mktemp) +trap "rm -f $TMP" 0 1 15 + +cat <<EOF >$TMP +new +neww sleep 101 +neww -- sleep 102 +neww "sleep 103" +EOF + +$TMUX -f$TMP start +[ $($TMUX lsw|wc -l) -eq 4 ] || exit 1 +$TMUX kill-server 2>/dev/null + +exit 0 diff --git a/regress/osc-11colours.sh b/regress/osc-11colours.sh new file mode 100644 index 00000000..a0dd605d --- /dev/null +++ b/regress/osc-11colours.sh @@ -0,0 +1,243 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null + +$TMUX -vv new -d +$TMUX set -g remain-on-exit on + +do_test() { + $TMUX splitw "printf '$1'" + c="$($TMUX display -p '#{pane_bg}')" + $TMUX kill-pane + [ "$c" != "$2" ] && return 1 + return 0 +} + +do_test '\033]11;rgb:ff/ff/ff\007' '#ffffff' || exit 1 +do_test '\033]11;rgb:ff/ff/ff\007\033]111\007' 'default' || exit 1 + +do_test '\033]11;cmy:0.9373/0.6941/0.4549\007' '#0f4e8b' || exit 1 +do_test '\033]11;cmyk:0.88/0.44/0.00/0.45\007' '#104e8c' || exit 1 + +do_test '\033]11;16,78,139\007' '#104e8b' || exit 1 +do_test '\033]11;#104E8B\007' '#104e8b' || exit 1 +do_test '\033]11;#10004E008B00\007' '#104e8b' || exit 1 +do_test '\033]11;DodgerBlue4\007' '#104e8b' || exit 1 +do_test '\033]11;DodgerBlue4 \007' '#104e8b' || exit 1 +do_test '\033]11; DodgerBlue4\007' '#104e8b' || exit 1 +do_test '\033]11;rgb:10/4E/8B\007' '#104e8b' || exit 1 +do_test '\033]11;rgb:1000/4E00/8B00\007' '#104e8b' || exit 1 + +do_test '\033]11;grey\007' '#bebebe' || exit 1 +do_test '\033]11;grey0\007' '#000000' || exit 1 +do_test '\033]11;grey1\007' '#030303' || exit 1 +do_test '\033]11;grey2\007' '#050505' || exit 1 +do_test '\033]11;grey3\007' '#080808' || exit 1 +do_test '\033]11;grey4\007' '#0a0a0a' || exit 1 +do_test '\033]11;grey5\007' '#0d0d0d' || exit 1 +do_test '\033]11;grey6\007' '#0f0f0f' || exit 1 +do_test '\033]11;grey7\007' '#121212' || exit 1 +do_test '\033]11;grey8\007' '#141414' || exit 1 +do_test '\033]11;grey9\007' '#171717' || exit 1 +do_test '\033]11;grey10\007' '#1a1a1a' || exit 1 +do_test '\033]11;grey11\007' '#1c1c1c' || exit 1 +do_test '\033]11;grey12\007' '#1f1f1f' || exit 1 +do_test '\033]11;grey13\007' '#212121' || exit 1 +do_test '\033]11;grey14\007' '#242424' || exit 1 +do_test '\033]11;grey15\007' '#262626' || exit 1 +do_test '\033]11;grey16\007' '#292929' || exit 1 +do_test '\033]11;grey17\007' '#2b2b2b' || exit 1 +do_test '\033]11;grey18\007' '#2e2e2e' || exit 1 +do_test '\033]11;grey19\007' '#303030' || exit 1 +do_test '\033]11;grey20\007' '#333333' || exit 1 +do_test '\033]11;grey21\007' '#363636' || exit 1 +do_test '\033]11;grey22\007' '#383838' || exit 1 +do_test '\033]11;grey23\007' '#3b3b3b' || exit 1 +do_test '\033]11;grey24\007' '#3d3d3d' || exit 1 +do_test '\033]11;grey25\007' '#404040' || exit 1 +do_test '\033]11;grey26\007' '#424242' || exit 1 +do_test '\033]11;grey27\007' '#454545' || exit 1 +do_test '\033]11;grey28\007' '#474747' || exit 1 +do_test '\033]11;grey29\007' '#4a4a4a' || exit 1 +do_test '\033]11;grey30\007' '#4d4d4d' || exit 1 +do_test '\033]11;grey31\007' '#4f4f4f' || exit 1 +do_test '\033]11;grey32\007' '#525252' || exit 1 +do_test '\033]11;grey33\007' '#545454' || exit 1 +do_test '\033]11;grey34\007' '#575757' || exit 1 +do_test '\033]11;grey35\007' '#595959' || exit 1 +do_test '\033]11;grey36\007' '#5c5c5c' || exit 1 +do_test '\033]11;grey37\007' '#5e5e5e' || exit 1 +do_test '\033]11;grey38\007' '#616161' || exit 1 +do_test '\033]11;grey39\007' '#636363' || exit 1 +do_test '\033]11;grey40\007' '#666666' || exit 1 +do_test '\033]11;grey41\007' '#696969' || exit 1 +do_test '\033]11;grey42\007' '#6b6b6b' || exit 1 +do_test '\033]11;grey43\007' '#6e6e6e' || exit 1 +do_test '\033]11;grey44\007' '#707070' || exit 1 +do_test '\033]11;grey45\007' '#737373' || exit 1 +do_test '\033]11;grey46\007' '#757575' || exit 1 +do_test '\033]11;grey47\007' '#787878' || exit 1 +do_test '\033]11;grey48\007' '#7a7a7a' || exit 1 +do_test '\033]11;grey49\007' '#7d7d7d' || exit 1 +do_test '\033]11;grey50\007' '#7f7f7f' || exit 1 +do_test '\033]11;grey51\007' '#828282' || exit 1 +do_test '\033]11;grey52\007' '#858585' || exit 1 +do_test '\033]11;grey53\007' '#878787' || exit 1 +do_test '\033]11;grey54\007' '#8a8a8a' || exit 1 +do_test '\033]11;grey55\007' '#8c8c8c' || exit 1 +do_test '\033]11;grey56\007' '#8f8f8f' || exit 1 +do_test '\033]11;grey57\007' '#919191' || exit 1 +do_test '\033]11;grey58\007' '#949494' || exit 1 +do_test '\033]11;grey59\007' '#969696' || exit 1 +do_test '\033]11;grey60\007' '#999999' || exit 1 +do_test '\033]11;grey61\007' '#9c9c9c' || exit 1 +do_test '\033]11;grey62\007' '#9e9e9e' || exit 1 +do_test '\033]11;grey63\007' '#a1a1a1' || exit 1 +do_test '\033]11;grey64\007' '#a3a3a3' || exit 1 +do_test '\033]11;grey65\007' '#a6a6a6' || exit 1 +do_test '\033]11;grey66\007' '#a8a8a8' || exit 1 +do_test '\033]11;grey67\007' '#ababab' || exit 1 +do_test '\033]11;grey68\007' '#adadad' || exit 1 +do_test '\033]11;grey69\007' '#b0b0b0' || exit 1 +do_test '\033]11;grey70\007' '#b3b3b3' || exit 1 +do_test '\033]11;grey71\007' '#b5b5b5' || exit 1 +do_test '\033]11;grey72\007' '#b8b8b8' || exit 1 +do_test '\033]11;grey73\007' '#bababa' || exit 1 +do_test '\033]11;grey74\007' '#bdbdbd' || exit 1 +do_test '\033]11;grey75\007' '#bfbfbf' || exit 1 +do_test '\033]11;grey76\007' '#c2c2c2' || exit 1 +do_test '\033]11;grey77\007' '#c4c4c4' || exit 1 +do_test '\033]11;grey78\007' '#c7c7c7' || exit 1 +do_test '\033]11;grey79\007' '#c9c9c9' || exit 1 +do_test '\033]11;grey80\007' '#cccccc' || exit 1 +do_test '\033]11;grey81\007' '#cfcfcf' || exit 1 +do_test '\033]11;grey82\007' '#d1d1d1' || exit 1 +do_test '\033]11;grey83\007' '#d4d4d4' || exit 1 +do_test '\033]11;grey84\007' '#d6d6d6' || exit 1 +do_test '\033]11;grey85\007' '#d9d9d9' || exit 1 +do_test '\033]11;grey86\007' '#dbdbdb' || exit 1 +do_test '\033]11;grey87\007' '#dedede' || exit 1 +do_test '\033]11;grey88\007' '#e0e0e0' || exit 1 +do_test '\033]11;grey89\007' '#e3e3e3' || exit 1 +do_test '\033]11;grey90\007' '#e5e5e5' || exit 1 +do_test '\033]11;grey91\007' '#e8e8e8' || exit 1 +do_test '\033]11;grey92\007' '#ebebeb' || exit 1 +do_test '\033]11;grey93\007' '#ededed' || exit 1 +do_test '\033]11;grey94\007' '#f0f0f0' || exit 1 +do_test '\033]11;grey95\007' '#f2f2f2' || exit 1 +do_test '\033]11;grey96\007' '#f5f5f5' || exit 1 +do_test '\033]11;grey97\007' '#f7f7f7' || exit 1 +do_test '\033]11;grey98\007' '#fafafa' || exit 1 +do_test '\033]11;grey99\007' '#fcfcfc' || exit 1 +do_test '\033]11;grey100\007' '#ffffff' || exit 1 + +do_test '\033]11;gray\007' '#bebebe' || exit 1 +do_test '\033]11;gray0\007' '#000000' || exit 1 +do_test '\033]11;gray1\007' '#030303' || exit 1 +do_test '\033]11;gray2\007' '#050505' || exit 1 +do_test '\033]11;gray3\007' '#080808' || exit 1 +do_test '\033]11;gray4\007' '#0a0a0a' || exit 1 +do_test '\033]11;gray5\007' '#0d0d0d' || exit 1 +do_test '\033]11;gray6\007' '#0f0f0f' || exit 1 +do_test '\033]11;gray7\007' '#121212' || exit 1 +do_test '\033]11;gray8\007' '#141414' || exit 1 +do_test '\033]11;gray9\007' '#171717' || exit 1 +do_test '\033]11;gray10\007' '#1a1a1a' || exit 1 +do_test '\033]11;gray11\007' '#1c1c1c' || exit 1 +do_test '\033]11;gray12\007' '#1f1f1f' || exit 1 +do_test '\033]11;gray13\007' '#212121' || exit 1 +do_test '\033]11;gray14\007' '#242424' || exit 1 +do_test '\033]11;gray15\007' '#262626' || exit 1 +do_test '\033]11;gray16\007' '#292929' || exit 1 +do_test '\033]11;gray17\007' '#2b2b2b' || exit 1 +do_test '\033]11;gray18\007' '#2e2e2e' || exit 1 +do_test '\033]11;gray19\007' '#303030' || exit 1 +do_test '\033]11;gray20\007' '#333333' || exit 1 +do_test '\033]11;gray21\007' '#363636' || exit 1 +do_test '\033]11;gray22\007' '#383838' || exit 1 +do_test '\033]11;gray23\007' '#3b3b3b' || exit 1 +do_test '\033]11;gray24\007' '#3d3d3d' || exit 1 +do_test '\033]11;gray25\007' '#404040' || exit 1 +do_test '\033]11;gray26\007' '#424242' || exit 1 +do_test '\033]11;gray27\007' '#454545' || exit 1 +do_test '\033]11;gray28\007' '#474747' || exit 1 +do_test '\033]11;gray29\007' '#4a4a4a' || exit 1 +do_test '\033]11;gray30\007' '#4d4d4d' || exit 1 +do_test '\033]11;gray31\007' '#4f4f4f' || exit 1 +do_test '\033]11;gray32\007' '#525252' || exit 1 +do_test '\033]11;gray33\007' '#545454' || exit 1 +do_test '\033]11;gray34\007' '#575757' || exit 1 +do_test '\033]11;gray35\007' '#595959' || exit 1 +do_test '\033]11;gray36\007' '#5c5c5c' || exit 1 +do_test '\033]11;gray37\007' '#5e5e5e' || exit 1 +do_test '\033]11;gray38\007' '#616161' || exit 1 +do_test '\033]11;gray39\007' '#636363' || exit 1 +do_test '\033]11;gray40\007' '#666666' || exit 1 +do_test '\033]11;gray41\007' '#696969' || exit 1 +do_test '\033]11;gray42\007' '#6b6b6b' || exit 1 +do_test '\033]11;gray43\007' '#6e6e6e' || exit 1 +do_test '\033]11;gray44\007' '#707070' || exit 1 +do_test '\033]11;gray45\007' '#737373' || exit 1 +do_test '\033]11;gray46\007' '#757575' || exit 1 +do_test '\033]11;gray47\007' '#787878' || exit 1 +do_test '\033]11;gray48\007' '#7a7a7a' || exit 1 +do_test '\033]11;gray49\007' '#7d7d7d' || exit 1 +do_test '\033]11;gray50\007' '#7f7f7f' || exit 1 +do_test '\033]11;gray51\007' '#828282' || exit 1 +do_test '\033]11;gray52\007' '#858585' || exit 1 +do_test '\033]11;gray53\007' '#878787' || exit 1 +do_test '\033]11;gray54\007' '#8a8a8a' || exit 1 +do_test '\033]11;gray55\007' '#8c8c8c' || exit 1 +do_test '\033]11;gray56\007' '#8f8f8f' || exit 1 +do_test '\033]11;gray57\007' '#919191' || exit 1 +do_test '\033]11;gray58\007' '#949494' || exit 1 +do_test '\033]11;gray59\007' '#969696' || exit 1 +do_test '\033]11;gray60\007' '#999999' || exit 1 +do_test '\033]11;gray61\007' '#9c9c9c' || exit 1 +do_test '\033]11;gray62\007' '#9e9e9e' || exit 1 +do_test '\033]11;gray63\007' '#a1a1a1' || exit 1 +do_test '\033]11;gray64\007' '#a3a3a3' || exit 1 +do_test '\033]11;gray65\007' '#a6a6a6' || exit 1 +do_test '\033]11;gray66\007' '#a8a8a8' || exit 1 +do_test '\033]11;gray67\007' '#ababab' || exit 1 +do_test '\033]11;gray68\007' '#adadad' || exit 1 +do_test '\033]11;gray69\007' '#b0b0b0' || exit 1 +do_test '\033]11;gray70\007' '#b3b3b3' || exit 1 +do_test '\033]11;gray71\007' '#b5b5b5' || exit 1 +do_test '\033]11;gray72\007' '#b8b8b8' || exit 1 +do_test '\033]11;gray73\007' '#bababa' || exit 1 +do_test '\033]11;gray74\007' '#bdbdbd' || exit 1 +do_test '\033]11;gray75\007' '#bfbfbf' || exit 1 +do_test '\033]11;gray76\007' '#c2c2c2' || exit 1 +do_test '\033]11;gray77\007' '#c4c4c4' || exit 1 +do_test '\033]11;gray78\007' '#c7c7c7' || exit 1 +do_test '\033]11;gray79\007' '#c9c9c9' || exit 1 +do_test '\033]11;gray80\007' '#cccccc' || exit 1 +do_test '\033]11;gray81\007' '#cfcfcf' || exit 1 +do_test '\033]11;gray82\007' '#d1d1d1' || exit 1 +do_test '\033]11;gray83\007' '#d4d4d4' || exit 1 +do_test '\033]11;gray84\007' '#d6d6d6' || exit 1 +do_test '\033]11;gray85\007' '#d9d9d9' || exit 1 +do_test '\033]11;gray86\007' '#dbdbdb' || exit 1 +do_test '\033]11;gray87\007' '#dedede' || exit 1 +do_test '\033]11;gray88\007' '#e0e0e0' || exit 1 +do_test '\033]11;gray89\007' '#e3e3e3' || exit 1 +do_test '\033]11;gray90\007' '#e5e5e5' || exit 1 +do_test '\033]11;gray91\007' '#e8e8e8' || exit 1 +do_test '\033]11;gray92\007' '#ebebeb' || exit 1 +do_test '\033]11;gray93\007' '#ededed' || exit 1 +do_test '\033]11;gray94\007' '#f0f0f0' || exit 1 +do_test '\033]11;gray95\007' '#f2f2f2' || exit 1 +do_test '\033]11;gray96\007' '#f5f5f5' || exit 1 +do_test '\033]11;gray97\007' '#f7f7f7' || exit 1 +do_test '\033]11;gray98\007' '#fafafa' || exit 1 +do_test '\033]11;gray99\007' '#fcfcfc' || exit 1 +do_test '\033]11;gray100\007' '#ffffff' || exit 1 + +$TMUX -f/dev/null kill-server 2>/dev/null +exit 0 diff --git a/regress/style-trim.sh b/regress/style-trim.sh new file mode 100644 index 00000000..56f93656 --- /dev/null +++ b/regress/style-trim.sh @@ -0,0 +1,93 @@ +#!/bin/sh + +PATH=/bin:/usr/bin +TERM=screen + +[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) +TMUX="$TEST_TMUX -Ltest" +$TMUX kill-server 2>/dev/null +TMUX2="$TEST_TMUX -Ltest2" +$TMUX2 kill-server 2>/dev/null + +$TMUX2 -f/dev/null new -d "$TMUX -f/dev/null new" +sleep 2 +$TMUX set -g status-style fg=default,bg=default + +check() { + v=$($TMUX display -p "$1") + $TMUX set -g status-format[0] "$1" + sleep 1 + r=$($TMUX2 capturep -Cep|tail -1|sed 's|\\033\[||g') + + #printf "$1 = [$v = $2] [$r = $3]" + if [ "$v" = "$2" -a "$r" = "$3" ]; then + : #printf " good\n" + else + #printf " \033[31mbad\033[0m\n" + exit 1 + fi +} + +# drawn as #0 +$TMUX setenv -g V '#0' +check '#{V} #{w:V}' '#0 2' '#0 2' +check '#{=3:V}' '#0' '#0' +check '#{=-3:V}' '#0' '#0' + +# drawn as #0 +$TMUX setenv -g V '###[bg=yellow]0' +check '#{V} #{w:V}' '###[bg=yellow]0 2' '#43m0 249m' +check '#{=3:V}' '###[bg=yellow]0' '#43m049m' +check '#{=-3:V}' '###[bg=yellow]0' '#43m049m' + +# drawn as #0123456 +$TMUX setenv -g V '#0123456' +check '#{V} #{w:V}' '#0123456 8' '#0123456 8' +check '#{=3:V}' '#01' '#01' +check '#{=-3:V}' '456' '456' + +# drawn as ##0123456 +$TMUX setenv -g V '##0123456' +check '#{V} #{w:V}' '##0123456 9' '##0123456 9' +check '#{=3:V}' '##0' '##0' +check '#{=-3:V}' '456' '456' + +# drawn as ###0123456 +$TMUX setenv -g V '###0123456' +check '#{V} #{w:V}' '###0123456 10' '###0123456 10' +check '#{=3:V}' '###' '###' +check '#{=-3:V}' '456' '456' + +# drawn as 0123456 +$TMUX setenv -g V '#[bg=yellow]0123456' +check '#{V} #{w:V}' '#[bg=yellow]0123456 7' '43m0123456 749m' +check '#{=3:V}' '#[bg=yellow]012' '43m01249m' +check '#{=-3:V}' '#[bg=yellow]456' '43m45649m' + +# drawn as #[bg=yellow]0123456 +$TMUX setenv -g V '##[bg=yellow]0123456' +check '#{V} #{w:V}' '##[bg=yellow]0123456 19' '#[bg=yellow]0123456 19' +check '#{=3:V}' '##[b' '#[b' +check '#{=-3:V}' '456' '456' + +# drawn as #0123456 +$TMUX setenv -g V '###[bg=yellow]0123456' +check '#{V} #{w:V}' '###[bg=yellow]0123456 8' '#43m0123456 849m' +check '#{=3:V}' '###[bg=yellow]01' '#43m0149m' +check '#{=-3:V}' '#[bg=yellow]456' '43m45649m' + +# drawn as ##[bg=yellow]0123456 +$TMUX setenv -g V '####[bg=yellow]0123456' +check '#{V} #{w:V}' '####[bg=yellow]0123456 20' '##[bg=yellow]0123456 20' +check '#{=3:V}' '####[' '##[' +check '#{=-3:V}' '456' '456' + +# drawn as ###0123456 +$TMUX setenv -g V '#####[bg=yellow]0123456' +check '#{V} #{w:V}' '#####[bg=yellow]0123456 9' '##43m0123456 949m' +check '#{=3:V}' '#####[bg=yellow]0' '##43m049m' +check '#{=-3:V}' '#[bg=yellow]456' '43m45649m' + +$TMUX kill-server 2>/dev/null +$TMUX2 kill-server 2>/dev/null +exit 0 |