mirror of
https://github.com/samoshkin/tmux-config.git
synced 2026-01-04 00:38:01 +00:00
Make possible to share remote and local copy buffer via local listener, SSH remote tunnel and nc on remote host
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
# so it do not stack together with local session's one
|
# so it do not stack together with local session's one
|
||||||
set -g status-position bottom
|
set -g status-position bottom
|
||||||
|
|
||||||
|
# Set port of SSH remote tunnel, where tmux will pipe buffers to transfer on local machine for copy
|
||||||
|
set -g @copy_backend_remote_tunnel_port 11988
|
||||||
|
|
||||||
# In remote mode we don't show "clock" and "battery status" widgets
|
# In remote mode we don't show "clock" and "battery status" widgets
|
||||||
set -g status-left "$wg_session"
|
set -g status-left "$wg_session"
|
||||||
set -g status-right "#{prefix_highlight} $wg_is_keys_off $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | #{online_status}"
|
set -g status-right "#{prefix_highlight} $wg_is_keys_off $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | #{online_status}"
|
||||||
|
|||||||
10
tmux/yank.sh
10
tmux/yank.sh
@@ -9,6 +9,8 @@ is_app_installed() {
|
|||||||
# get data either form stdin or from file
|
# get data either form stdin or from file
|
||||||
buf=$(cat "$@")
|
buf=$(cat "$@")
|
||||||
|
|
||||||
|
copy_backend_remote_tunnel_port=$(tmux show-option -gvq "@copy_backend_remote_tunnel_port")
|
||||||
|
|
||||||
# Resolve copy backend: pbcopy (OSX), reattach-to-user-namespace (OSX), xclip/xsel (Linux)
|
# Resolve copy backend: pbcopy (OSX), reattach-to-user-namespace (OSX), xclip/xsel (Linux)
|
||||||
copy_backend=""
|
copy_backend=""
|
||||||
if is_app_installed pbcopy; then
|
if is_app_installed pbcopy; then
|
||||||
@@ -19,17 +21,17 @@ elif [ -n "${DISPLAY-}" ] && is_app_installed xsel; then
|
|||||||
copy_backend="xsel -i --clipboard"
|
copy_backend="xsel -i --clipboard"
|
||||||
elif [ -n "${DISPLAY-}" ] && is_app_installed xclip; then
|
elif [ -n "${DISPLAY-}" ] && is_app_installed xclip; then
|
||||||
copy_backend="xclip -i -f -selection primary | xclip -i -selection clipboard"
|
copy_backend="xclip -i -f -selection primary | xclip -i -selection clipboard"
|
||||||
|
elif [ -n "${copy_backend_remote_tunnel_port-}" ] && [ "$(ss -n -4 state listening "( sport = $copy_backend_remote_tunnel_port )" | tail -n +2 | wc -l)" -eq 1 ]; then
|
||||||
|
copy_backend="nc localhost $copy_backend_remote_tunnel_port"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if copy backend is resolved, copy and exit
|
# if copy backend is resolved, copy and exit
|
||||||
if [ -n "$copy_backend" ]; then
|
if [ -n "$copy_backend" ]; then
|
||||||
printf "$buf" | eval "$copy_backend"
|
printf "$buf" | eval "$copy_backend"
|
||||||
exit;
|
exit;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: send to local socket which is remote tunneled to "pbcopy|xclip" listener on local machine
|
# If no copy backends were eligible, fallback to OSC 52 escape sequences
|
||||||
# TODO: otherwise fallback to OSC 52 escape sequence
|
|
||||||
|
|
||||||
# Copy via OSC 52 ANSI escape sequence to controlling terminal
|
# Copy via OSC 52 ANSI escape sequence to controlling terminal
|
||||||
buflen=$( printf %s "$buf" | wc -c )
|
buflen=$( printf %s "$buf" | wc -c )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user