diff --git a/splitAUTHENTICATION b/splitAUTHENTICATION new file mode 100644 index 0000000..f3b0390 --- /dev/null +++ b/splitAUTHENTICATION @@ -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 +} +# }}} diff --git a/splitUPDATE b/splitUPDATE new file mode 100644 index 0000000..969b751 --- /dev/null +++ b/splitUPDATE @@ -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}' +} +# }}} diff --git a/tmux.conf b/tmux.conf index b339167..92fac89 100644 --- a/tmux.conf +++ b/tmux.conf @@ -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" #Copy CLIPBOARD to tmux buffer and paste-it in tmux 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 v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer" # Copy-mode unbind PPage @@ -229,6 +229,18 @@ bind C-_ choose-session unbind c-h bind c-h set -g status +# Load splits (with + 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 {{{ @@ -242,9 +254,6 @@ set -g lock-after-time 1800 # Use both cmatrix (if available) and 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 {{{