added support for connecting to the same host when creating a new window from a pane running an SSH session, resolves #632
see tmux_conf_new_window_reconnect_ssh also fixed toggling tmux_conf_xxx_reconnect_ssh back and forth
This commit is contained in:
parent
79430acd85
commit
55d47e9c15
2 changed files with 71 additions and 19 deletions
65
.tmux.conf
65
.tmux.conf
|
@ -701,6 +701,33 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# esac
|
||||
# }
|
||||
#
|
||||
# _new_window_ssh() {
|
||||
# pane_pid=${1:-$(tmux display -p '#{pane_pid}')}
|
||||
# pane_tty=${2:-$(tmux display -p '#{b:pane_tty}')}
|
||||
# shift 2
|
||||
#
|
||||
# pane_info=$(_pane_info "$pane_pid" "$pane_tty")
|
||||
# command=${pane_info#*:}
|
||||
# command=${command#*:}
|
||||
#
|
||||
# case "$command" in
|
||||
# *mosh-client*)
|
||||
# # shellcheck disable=SC2046
|
||||
# tmux new-window "$@" mosh $(echo "$command" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/')
|
||||
# ;;
|
||||
# *ssh*)
|
||||
# # shellcheck disable=SC2046
|
||||
# tmux new-window "$@" $(echo "$command" | sed -e 's/;/\\;/g')
|
||||
# ;;
|
||||
# *)
|
||||
# tmux new-window "$@"
|
||||
# esac
|
||||
# }
|
||||
#
|
||||
# _new_window() {
|
||||
# _new_window_ssh "$@"
|
||||
# }
|
||||
#
|
||||
# _split_window_ssh() {
|
||||
# pane_pid=${1:-$(tmux display -p '#{pane_pid}')}
|
||||
# pane_tty=${2:-$(tmux display -p '#{b:pane_tty}')}
|
||||
|
@ -786,32 +813,48 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# # output of list-keys can be truncated
|
||||
# perl -p -i -e "s/'#\{\?window_zoomed_flag,Unzoom,Zoom\}' 'z' \{resize-pane -$/'#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}\"/g" "$cfg"
|
||||
#
|
||||
# tmux_conf_new_window_retain_current_path=${tmux_conf_new_window_retain_current_path:-false}
|
||||
# tmux_conf_new_window_retain_current_path=${tmux_conf_new_window_retain_current_path:-true}
|
||||
# if ! _is_disabled "$tmux_conf_new_window_retain_current_path"; then
|
||||
# perl -p -i -e "
|
||||
# s/\brun-shell\b\s+(\"|')cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_new_window\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^\n\1]*?)(?:\s+-c\s+((?:\\\\{1,3}\")?|\"?|'?)#\{pane_current_path\}\4)([^\n\1]*?)\1/run-shell \1cut -c3- \2 | sh -s _new_window #\{pane_pid\} #\{b:pane_tty\}\3\5\1/g
|
||||
# ;
|
||||
# s/\brun-shell\b\s+(\"|')cut\s+-c3-\s+.+?\s+\|\s+sh\s+-s\s+_new_window\s+#\{pane_pid\}\s+#\{b:pane_tty\}(\s+.+?)?\1/new-window\2/g
|
||||
# ;
|
||||
# s/\bnew-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\2)/new-window\1/g" \
|
||||
# "$cfg"
|
||||
# fi
|
||||
#
|
||||
# tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-true}
|
||||
# if ! _is_disabled "$tmux_conf_new_pane_retain_current_path"; then
|
||||
# perl -p -i -e "
|
||||
# s/\brun-shell\b\s+(\"|')cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_split_window\s+#\{b:pane_tty\}([^\n\1]*)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\4)([^\n\1]*)\1/run-shell \1cut -c3- \2 | sh -s _split_window #\{pane_pid\} #\{b:pane_tty\}\3\5\1/g
|
||||
# ;
|
||||
# s/\brun-shell\b(?:\s+((?:\\\\\")?|\"?|'?)cut\s+-c3-\s+(?:.+?)\s+\|\s+sh\s+-s\s+_split_window\s+((?:\\\\\")?|\"?|'?)#\{b:pane_tty\}\2)(.*?)\1/split-window\3/g
|
||||
# ;
|
||||
# s/\bsplit-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" \
|
||||
# s,\bnew-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?(?:\s+(\bssh\b))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?,run-shell 'cut -c3- \"$TMUX_CONF\" | sh -s _new_window_ssh #\{pane_pid\} #\{b:pane_tty\}\1',g if /\bnew-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?(?:\s+(ssh))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?/"\
|
||||
# "$cfg"
|
||||
#
|
||||
# tmux_conf_new_window_reconnect_ssh=${tmux_conf_new_window_reconnect_ssh:-false}
|
||||
# if ! _is_disabled "$tmux_conf_new_window_reconnect_ssh" && _is_true "$tmux_conf_new_window_reconnect_ssh"; then
|
||||
# perl -p -i -e "s,\bnew-window\b([^;}\n\"]*),run-shell 'cut -c3- \"$TMUX_CONF\" | sh -s _new_window #\{pane_pid\} #\{b:pane_tty\}\1',g" "$cfg"
|
||||
# fi
|
||||
#
|
||||
# if ! _is_disabled "$tmux_conf_new_window_retain_current_path"; then
|
||||
# if _is_true "$tmux_conf_new_window_retain_current_path"; then
|
||||
# tmux_conf_new_window_retain_current_path=${tmux_conf_new_window_retain_current_path:-false}
|
||||
# if ! _is_disabled "$tmux_conf_new_window_retain_current_path" && _is_true "$tmux_conf_new_window_retain_current_path"; then
|
||||
# perl -p -i -e "
|
||||
# s/\bnew-window\b(?!\s+(?:-|}))/{$&}/g if /\bdisplay-menu\b/
|
||||
# ;
|
||||
# s/\bnew-window\b/new-window -c '#\{pane_current_path\}'/g" \
|
||||
# s/\bnew-window\b/new-window -c '#{pane_current_path}'\1/g
|
||||
# ;
|
||||
# s/\brun-shell\b\s+'cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_new_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- \1 | sh -s _new_window\2 #\{pane_pid\} #\{b:pane_tty\} -c \\\\\"#\{pane_current_path\}\\\\\"\3'/g if /\bdisplay-menu\b/
|
||||
# ;
|
||||
# s/\brun-shell\b\s+'cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_new_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- \1 | sh -s _new_window\2 #\{pane_pid\} #\{b:pane_tty\} -c \"#\{pane_current_path\}\"\3'/g" \
|
||||
# "$cfg"
|
||||
# fi
|
||||
|
||||
# tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-true}
|
||||
# if ! _is_disabled "$tmux_conf_new_pane_retain_current_path"; then
|
||||
# perl -p -i -e "
|
||||
# s/\brun-shell\b\s+(\"|')cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^\n\1]*?)(?:\s+-c\s+((?:\\\\{1,3}\")?|\"?|'?)#\{pane_current_path\}\4)([^\n\1]*?)\1/run-shell \1cut -c3- \2 | sh -s _split_window #\{pane_pid\} #\{b:pane_tty\}\3\5\1/g
|
||||
# ;
|
||||
# s/\brun-shell\b\s+(\"|')cut\s+-c3-\s+.+?\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_pid\}\s+#\{b:pane_tty\}(\s+.+?)?\1/split-window\2/g
|
||||
# ;
|
||||
# s/\bsplit-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" \
|
||||
# "$cfg"
|
||||
# fi
|
||||
#
|
||||
# perl -p -i -e "
|
||||
|
|
|
@ -5,6 +5,15 @@
|
|||
# Copyright 2012— Gregory Pakosz (@gpakosz).
|
||||
|
||||
|
||||
# -- session creation ----------------------------------------------------------
|
||||
|
||||
# prompt for session name when creating a new session, possible values are:
|
||||
# - true
|
||||
# - false (default)
|
||||
# - disabled (do not modify new-session bindings)
|
||||
tmux_conf_new_session_prompt=false
|
||||
|
||||
|
||||
# -- windows & pane creation ---------------------------------------------------
|
||||
|
||||
# new window retains current path, possible values are:
|
||||
|
@ -13,6 +22,12 @@
|
|||
# - disabled (do not modify new-window bindings)
|
||||
tmux_conf_new_window_retain_current_path=false
|
||||
|
||||
# new window tries to reconnect ssh sessions, possible values are:
|
||||
# - true
|
||||
# - false (default)
|
||||
# - disabled (do not modify new-window bindings)
|
||||
tmux_conf_new_window_reconnect_ssh=false
|
||||
|
||||
# new pane retains current path, possible values are:
|
||||
# - true (default)
|
||||
# - false
|
||||
|
@ -25,12 +40,6 @@ tmux_conf_new_pane_retain_current_path=true
|
|||
# - disabled (do not modify split-window bindings)
|
||||
tmux_conf_new_pane_reconnect_ssh=false
|
||||
|
||||
# prompt for session name when creating a new session, possible values are:
|
||||
# - true
|
||||
# - false (default)
|
||||
# - disabled (do not modify new-session bindings)
|
||||
tmux_conf_new_session_prompt=false
|
||||
|
||||
|
||||
# -- display -------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in a new issue