New bind and splits for update and authentication

This commit is contained in:
Jeremy Gardais 2023-01-24 13:21:04 +01:00
parent 544522c678
commit f6b1010c55
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
3 changed files with 93 additions and 4 deletions

58
splitAUTHENTICATION Normal file
View File

@ -0,0 +1,58 @@
### Session --------------------------------------------------------------
# -sXX : XX session ID or name
# -nWINDOW_NAME : Name of the window…
# -d : Don't attache to the new session/window/pane/…
# -tXX:YY.ZZ :
# XX : session ID or name
# YY : (optional) Window ID
# ZZ : (optional) Pane ID
# YY and ZZ should exists to be able to change the parameters,…
# monitor-activity : permet de mettre en avant une fenêtre quand son contenu reçoit un événement
# 'exec ${SHELL}': Allow to keep the pane running after the program exists
# Manage a new window and splits for authentication
# If a session already exists {{{
#if-shell -b 'tmux has-session' {
## Temp window to ensure a ssh-agent is running
#new-window -nAuth 'ssh-agent -a "${SSH_AGENT_SOCK}" ; logout'
## Window for authentication tools
#display-message "Create a new window for Authentication"
#new-window -nAuth 'gpg --quiet --for-your-eyes-only --decrypt ~/.password-store/test.gpg ; logout'
#split-window -h 'ssh-add -l | grep -qi -- "(ed25519)" || ssh-add ~/.ssh/id_ed25519 ; logout'
#set-window-option synchronize-panes on
#}
# }}}
# If file was source OUTSIDE of a running tmux {{{
if-shell -b 'test -z $TMUX' {
## Attach the last session
attach-session
## Temp window to ensure a ssh-agent is running
new-window -nSSH-Agent 'ssh-agent -a "${SSH_AGENT_SOCK}" ; logout'
## Window for authentication tools
display-message "Create a new window for Authentication"
new-window -nAuthTerm 'gpg --quiet --for-your-eyes-only --decrypt ~/.password-store/test.gpg ; tmux detach'
split-window -h 'ssh-add -l | grep -qi -- "(ed25519)" || ssh-add ~/.ssh/id_ed25519 ; logout'
set-window-option synchronize-panes on
#detach-client
}
# }}}
# If file was source from a running tmux {{{
if-shell -b 'test -n $TMUX' {
## Temp window to ensure a ssh-agent is running
new-window -nSSH-Agent 'ssh-agent -a "${SSH_AGENT_SOCK}" ; logout'
## Window for authentication tools
display-message "Create a new window for Authentication"
new-window -nAuthTmux 'gpg --quiet --for-your-eyes-only --decrypt ~/.password-store/test.gpg ; logout'
split-window -h 'ssh-add -l | grep -qi -- "(ed25519)" || ssh-add ~/.ssh/id_ed25519 ; logout'
set-window-option synchronize-panes on
}
# }}}

22
splitUPDATE Normal file
View File

@ -0,0 +1,22 @@
### Session --------------------------------------------------------------
# -sXX : XX session ID or name
# -nWINDOW_NAME : Name of the window…
# -d : Don't attache to the new session/window/pane/…
# -tXX:YY.ZZ :
# XX : session ID or name
# YY : (optional) Window ID
# ZZ : (optional) Pane ID
# YY and ZZ should exists to be able to change the parameters,…
# monitor-activity : permet de mettre en avant une fenêtre quand son contenu reçoit un événement
# 'exec ${SHELL}': Allow to keep the pane running after the program exists
# Manage new window for APT update
# If a session already exists {{{
if-shell -b 'tmux has-session' {
# Window for system update
display-message "Create a new window for system update"
new-window -nAPT 'sudo apt update ; sudo aptitude full-upgrade ; sudo aptitude clean ; exec ${SHELL}'
}
# }}}

View File

@ -97,8 +97,8 @@ bind-key C-y run-shell -b "tmux save-buffer - | xclip -i -selection clipboard"
bind-key y run-shell -b "tmux save-buffer - | xclip -i -selection clipboard" bind-key y run-shell -b "tmux save-buffer - | xclip -i -selection clipboard"
#Copy CLIPBOARD to tmux buffer and paste-it in tmux #Copy CLIPBOARD to tmux buffer and paste-it in tmux
unbind C-v unbind C-v
bind-key v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
bind-key C-v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer" bind-key C-v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
bind-key v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
# Copy-mode # Copy-mode
unbind PPage unbind PPage
@ -229,6 +229,18 @@ bind C-_ choose-session
unbind c-h unbind c-h
bind c-h set -g status bind c-h set -g status
# Load splits (with <prefix> + s + Extra key)
## Define a first key
unbind s
bind-key -T prefix s switch-client -T prefix_s
## Default s binding
bind-key -T prefix_s s choose-session
## Then splits
bind-key -T prefix_s i source-file ~/.tmux/splitAUTHENTICATION
bind-key -T prefix_s u source-file ~/.tmux/splitUPDATE
# Initialize sessions
bind I source-file ~/.tmux/splitWORKSTATION
### }}} ### }}}
### Configuration {{{ ### Configuration {{{
@ -242,9 +254,6 @@ set -g lock-after-time 1800
# Use both cmatrix (if available) and physlock # Use both cmatrix (if available) and physlock
if 'command -v cmatrix' 'set -g lock-command "cmatrix -s && physlock"' 'set -g lock-command physlock' if 'command -v cmatrix' 'set -g lock-command "cmatrix -s && physlock"' 'set -g lock-command physlock'
# Initialize sessions
bind I source-file ~/.tmux/splitWORKSTATION
### }}} ### }}}
### session {{{ ### session {{{