Commit 9ba5b0f4 authored by Perceval Guillou's avatar Perceval Guillou

Merge branch '738-scrolling-with-tmux' into 'master'

Resolve "scrolling with tmux"

Closes #738

See merge request !1287
parents ad8b9e98 32d96b3f
#=== Define default shell to use ===================================
#set-option -g default-shell /usr/bin/zsh
#=== Enable mouse in a virtual terminal (> version 2.1) ============
#=== Monitor activity ==============================================
#setw -g monitor-activity on
#=== delay for escape key press ====================================
# Reduce delay for escape key press (millisec)
set -g escape-time 50
#=== Use 256-colors ================================================
#set -g default-terminal screen-256color
#=== Enable mouse mode in a virtual terminal (> version 2.1) =======
set-option -g mouse on
#=== Modify the prefix =============================================
set-option -g prefix C-a
# if commented, use the default one : Control-b
# (we prefer to keep Control-a to go to begining of the line.)
# set-option -g prefix C-a
#=== No status bar =================================================
set-option -g status off
#=== Use larger history buffer =====================================
set -g history-limit 100000
#=== Use vi copy-mode ==============================================
set-window-option -g mode-keys vi
#===Define separator for the Word selection=========================
set-option -g word-separators "; @()\'\`\"" #"
#===================================================================
#======================== KEYS BINDINGS ============================
#===================================================================
#=== keep Native xterm scrolling ===================================
# useful to keep S-PageUp Binding to scroll up half a page
#set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
#set -ga terminal-overrides ',xterm*:smcup@:rmcup@'
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
#=== Bind F5 to switch window and clear copy selection =============
bind -n F5 if -F -t= '#{pane_in_mode}' 'send -X cancel' \; next-window
#=== Bind Ctrl-c to escape scan display function ===================
#=== switch to bliss repl window and stop ongoing scan =============
bind -n C-c if -F '#{==:#W,scan}' 'next-window' \; send -t bliss C-c
#=== Copy paste with mouse =========================================
#=== Bind pageup to enter copy mode and scroll one page=============
bind -n S-PageUp select-pane \; copy-mode -eu
bind -n S-PageDown select-pane \; if -F -t= '#{pane_in_mode}' 'send -X page-down'
bind -n S-Home select-pane \; copy-mode -e \; send -X history-top
bind -n S-End select-pane \; if -F -t= '#{pane_in_mode}' 'send -X cancel'
#====================================================================
#============================= MOUSE ================================
#====================================================================
#---Copy with Left click dragged (using 'primary' buffer instead of 'clipboard')
#=== Copy paste with mouse ==========================================
#===Copy with Left click dragged (using 'primary' buffer instead of 'clipboard')======
unbind -Tcopy-mode-vi MouseDragEnd1Pane
# bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection \; run "tmux save-buffer - | xclip -i -selection primary > /dev/null && tmux save-buffer - | xclip -i -selection clipboard > /dev/null"
bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-pipe "xclip -in -selection primary"
#---Paste with Middle click (using 'primary' buffer instead of 'clipboard')
#===Paste with Middle click (using 'primary' buffer instead of 'clipboard')============
unbind -n MouseDown2Pane
bind -n MouseDown2Pane select-pane\; run "tmux set-buffer \"$(xclip -o -selection primary)\"; tmux paste-buffer" \; if -F -t= '#{pane_in_mode}' 'send -X cancel'
#---Double Left Mouse Button Select & Copy (Word)
#===Double Left Mouse Button Select & Copy (Word)====================
bind -T copy-mode-vi DoubleClick1Pane select-pane \; send-keys -X select-word \; send-keys -X copy-pipe "xclip -in -sel primary"
bind -n DoubleClick1Pane select-pane \; copy-mode -M \; send-keys -X select-word \; send-keys -X copy-pipe "xclip -in -sel primary"
bind -n DoubleClick1Pane select-pane \; copy-mode -eM \; send-keys -X select-word \; send-keys -X copy-pipe "xclip -in -sel primary"
#---Triple Left Mouse Button Select & Copy (Line)
#===Triple Left Mouse Button Select & Copy (Line)====================
bind -T copy-mode-vi TripleClick1Pane select-pane \; send-keys -X select-line \; send-keys -X copy-pipe "xclip -in -sel primary"
bind -n TripleClick1Pane select-pane \; copy-mode -M \; send-keys -X select-line \; send-keys -X copy-pipe "xclip -in -sel primary"
bind -n TripleClick1Pane select-pane \; copy-mode -eM \; send-keys -X select-line \; send-keys -X copy-pipe "xclip -in -sel primary"
#---Exit copy-mode with a Right click
#===Exit copy-mode with a Right click================================
bind -Tcopy-mode-vi MouseDown3Pane if -F -t= '#{pane_in_mode}' 'send -X cancel'
#---Define separator for the Word selection
set-option -g word-separators "; @()\'\`\"" #"
#---Native xterm scrolling
#set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
#set -ga terminal-overrides ',xterm*:smcup@:rmcup@'
#set -g terminal-overrides 'xterm*:smcup@:rmcup@'
#=== THEME ==========================================================
#set -g status-bg black
#set -g status-fg white
#set -g window-status-current-bg white
#set -g window-status-current-fg black
#set -g window-status-current-attr bold
#set -g status-interval 60
#set -g status-left-length 30
#set -g status-left '#[fg=green](#S) #(whoami)'
#set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'
#=== DESIGN CHANGES =================================================
#===loud or quiet?===================================================
#set-option -g visual-activity off
#set-option -g visual-bell off
#set-option -g visual-silence off
#set-window-option -g monitor-activity off
#set-option -g bell-action none
#=== Tip and tricks =============================================
#===modes============================================================
#setw -g clock-mode-colour colour5
#setw -g mode-attr bold
#setw -g mode-fg colour1
#setw -g mode-bg colour18
#---Display a message
#bind -n m set-option mouse\; display-message "Mouse is now #{?mouse,on,off}"
#===panes============================================================
#set -g pane-border-bg colour0
#set -g pane-border-fg colour19
#set -g pane-active-border-bg colour0
#set -g pane-active-border-fg colour9
#===statusbar========================================================
#set -g status-position bottom
#set -g status-justify left
#set -g status-bg colour18
#set -g status-fg colour137
#set -g status-attr dim
#set -g status-left ''
#set -g status-right '#[fg=colour233,bg=colour19,bold] %d/%m #[fg=colour233,bg=colour8,bold] %H:%M:%S '
#set -g status-right-length 50
#set -g status-left-length 20
#setw -g window-status-current-fg colour1
#setw -g window-status-current-bg colour19
#setw -g window-status-current-attr bold
#setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F '
#setw -g window-status-fg colour9
#setw -g window-status-bg colour18
#setw -g window-status-attr none
#setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
#setw -g window-status-bell-attr bold
#setw -g window-status-bell-fg colour255
#setw -g window-status-bell-bg colour1
#===messages=========================================================
#set -g message-attr bold
#set -g message-fg colour232
#set -g message-bg colour16
#=== Tip and tricks =================================================
#===Display a message
#bind -n m set-option mouse\; display-message "Mouse is now #{?mouse,on,off}"
#===Use clipboard options============================================
#set -g set-clipboard on
#---Unbind all keys
#===Unbind all keys==================================================
#unbind -a
#unbind -a -Tcopy-mode
#unbind -a -Tcopy-mode-vi
#---Turn the mouse on, but without copy mode dragging
#===Turn the mouse on, but without copy mode dragging================
#unbind -n MouseDrag1Pane
#unbind -Tcopy-mode MouseDrag1Pane
#unbind -Tcopy-mode MouseDragEnd1Pane
#===Copy-Paste=======================================================
#bind -Tcopy-mode-vi MouseDown1Pane select-pane
#bind -Tcopy-mode-vi MouseDrag1Pane select-pane\; send -X begin-selection
#bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel
......@@ -73,20 +176,9 @@ set-option -g word-separators "; @()\'\`\"" #"
#bind -Tcopy-mode-vi DoubleClick1Pane select-pane\; send -X select-word
#bind -Tcopy-mode-vi TripleClick1Pane select-pane\; send -X select-line
#---???---------
#===Copy-Paste=======================================================
#bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -M\" \"send-keys -M\"' 'copy-mode -M'
#bind -n MouseDown3Pane if-shell -Ft= '#{mouse_any_flag}' 'select-pane -t=; send-keys -M' 'select-pane -mt='
#bind -n WheelUpPane if-shell -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= \"#{pane_in_mode}\" \"send-keys -M\" \"copy-mode -et=\"'
#bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"
#---Native xterm scrolling
#set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
#set -ga terminal-overrides ',xterm*:smcup@:rmcup@'
#set -g terminal-overrides 'xterm*:smcup@:rmcup@'
......@@ -8,33 +8,38 @@ provided to easily and interactively execute BLISS *commands* and
Use `-h` flag to get help about bliss command line interface:
% bliss -h
Usage: bliss [-l | --log-level=<log_level>] [-s <name> | --session=<name>] [--no-tmux]
bliss [-v | --version]
bliss [-c <name> | --create=<name>]
bliss [-d <name> | --delete=<name>]
bliss [-h | --help]
bliss --show-sessions
bliss --show-sessions-only
Options:
-l, --log-level=<log_level> Log level [default: WARN] (CRITICAL ERROR INFO DEBUG NOTSET)
-s, --session=<session_name> Start with the specified session
-v, --version Show version and exit
-c, --create=<session_name> Create a new session with the given name
-d, --delete=<session_name> Delete the given session
-h, --help Show help screen and exit
--no-tmux Deactivate Tmux usage
--show-sessions Display available sessions and tree of sub-sessions
--show-sessions-only Display available sessions names only
```
% bliss -h
Usage: bliss [-l | --log-level=<log_level>] [-s <name> | --session=<name>]
[--no-tmux]
bliss [-v | --version]
bliss [-c <name> | --create=<name>]
bliss [-d <name> | --delete=<name>]
bliss [-h | --help]
bliss --show-sessions
bliss --show-sessions-only
Options:
-l, --log-level=<log_level> Log level [default: WARN]
{CRITICAL; ERROR; INFO; DEBUG; NOTSET}
-s, --session=<session_name> Start with the specified session
-v, --version Show version and exit
-c, --create=<session_name> Create a new session with the given name
-d, --delete=<session_name> Delete the given session
-h, --help Show help screen and exit
--no-tmux Deactivate Tmux usage
--show-sessions Display sessions and tree of sub-sessions
--show-sessions-only Display sessions names only
```
### Version
Use `-v` or `--version` option to get the current version of a BLISS installation:
% bliss --version
BLISS version 0.2
```
% bliss --version
BLISS version 0.2
```
### Logging level
......@@ -43,37 +48,44 @@ Use `-v` or `--version` option to get the current version of a BLISS installatio
### Sessions
Use `-s` to start an existing session:
% bliss -s test_session
__ __ __
|__) | | /__` /__`
|__) |__ | .__/ .__/
```
% bliss -s test_session
__ __ __
|__) | | /__` /__`
|__) |__ | .__/ .__/
Welcome to BLISS version 1e7eb5c2 running on PCGUILLOU (in bliss_env Conda environment)
Copyright (c) ESRF, 2015-2018
Welcome to BLISS version erbs5c2 running on PCGUILLOU
in bliss_env Conda environment
Copyright (c) ESRF, 2015-2019
```
Use `--show-sessions` option to get the list of available sessions:
% bliss --show-sessions
Available BLISS sessions are:
flint
lima_test_session
test_session
```
% bliss --show-sessions
Available BLISS sessions are:
flint
lima_test_session
test_session
```
Other commands are also displaying the available sessions:
% bliss --show-sessions-only
#### Automatic creation of a new session
#### Creation of a new session
Use `--create` or `-c` to create the skeleton of a new session:
bliss -c eh1
% bliss -c eh1
creating 'eh1' session
Creating: /bliss/users/guilloud/local/beamline_configuration/sessions/eh1_setup.py
Creating: /bliss/users/guilloud/local/beamline_configuration/sessions/eh1.yml
Creating: /bliss/users/guilloud/local/beamline_configuration/sessions/scripts/eh1.py
```
bliss -c eh1
% bliss -c eh1
creating 'eh1' session
Creating: /.../local/beamline_configuration/sessions/eh1_setup.py
Creating: /.../local/beamline_configuration/sessions/eh1.yml
Creating: /.../local/beamline_configuration/sessions/scripts/eh1.py
```
#### Removing an existing session
......@@ -83,9 +95,82 @@ Use `--create` or `-c` to create the skeleton of a new session:
* setup file
* default session script (see above)
## Multiple panels (Tmux)
The BLISS shell uses *Tmux* to handle multiple **panels**:
* The default one is the *"Bliss shell panel"* used to enter user
commands and to display majority of answers to commands.
* The *Scan panel* is used to display output of scans. It is
automaticaly displayed when a scan starts.
This behaviour has been introduced in order to avoid the used to be
flooded by scan outputs.
The `F5` key is used to switch between thoses two panels.
#### Deactivating Tmux (terminal multiplexer) usage
Use `--no-tmux` to start a Bliss session without the Tmux terminal multiplexer.
In a Bliss session without Tmux, the scans output won't be printed in a separated window and will be shown in the main command line window.
Use `--no-tmux` to start a Bliss session without the Tmux terminal
multiplexer. In a Bliss session without Tmux, the scans output won't
be printed in a separated window and will be shown in the main command
line window.
```
% bliss -s test_session --no-tmux
```
### Mouse and Key bindings in Tmux
* `MouseButtonLeft`:
* drag to select area.
* `MouseButtonMiddle`:
* Paste current selection
* `MouseButtonRight`:
* exit copy-mode
* `Up` or `Ctrl-p`: go one *line* up in history (line per line if multi-line command)
* `Down` or `Ctrl-n`: go one *line* down in history (line per line if multi-line command)
* `Ctrl-Left` or `Alt-b`: jump to begining of (previous) word
* `Ctrl-Right` or `Alt-f`: jump to end of (next) word
* `PageUp`: go one *command* up in history (group of lines if multi-line command)
* `PageDown`: go one *command* down in history (group of lines if multi-line command)
* `Ctrl-a` or `Home`: go to begining of the current line
* `Ctrl-e` or `End`: go to end of the current line
* `Shift-PageUp`: Scroll up terminal buffer by half a page
* `Shift-PageDown`: Scroll down terminal buffer by half a page
* `Shift-Up`: Scroll up terminal buffer by one line
* `Shift-Down`: Scroll down terminal buffer by one line
* `Shift-Home`: go to begining of terminal buffer
* `Shift-End`: go to end of terminal buffer
* `Ctrl-s`: search in current command
* Cutting and Pasting:
* `Ctrl-w`: Cut the word before the cursor, adding it to the clipboard.
* `Ctrl-k`: (emacs mode) Cut the part of the line after the
cursor, adding it to the clipboard.
* `Ctrl-u`: Cut the part of the line before the cursor, adding it to the clipboard.
* `Ctrl-y`: (emacs mode) Paste the last thing you cut from the
clipboard. The `y` here stands for “yank”.
* `Ctrl-Shift-_`: Undo your last key press. You can repeat this to undo multiple times.
* Function keys:
* `F1`: ?
* `F2`: *ptpython* Menu
* `F3`: history mode:
* BLISS shell is hidden
* terminal is split into two new panels: *history* and *temporary buffer*
* navigation in history is done with usual keys (`arrows` of `Ctrl-<key>`)
* hitting `Space` copy the current history line into temporary buffer
* hitting `Enter` switches back to BLISS shell with temporary buffer pasted
* `F4`: switches `emacs` / `vi` mode (but why the hell to use vi ?)
* `F5`: switches between *BLISS commands shell* and *scan display panel*
* `F6`: switches to *paste mode* to paste code from external
application forcing no automatic indentation.
% bliss -s test_session --no-tmux
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment