Plumber + vt: accessing remote Unix files
It’s possible to use OSC 7
extension for easier plumbing of paths displayed in vt(1).
First, for each machine you’re planning to ssh+vt into, set up sshfs(4). Example:
sshfs -s myhost -r / myhost
plumb 'Local mount -c /srv/myhost /n/myhost'
The name in “/n/myhost” path MUST be the hostname of the remote machine - run hostname
there to check.
For the remote shell to start sending OSC 7
messages, follow
these instructions. You might want to replace ${HOSTNAME}
with ${HOSTNAME%.lan}
to get rid of .lan
suffix, depending on how your hosts are shown in /n/...
.
If you intend to use tmux
, it’s required to pass OSC 7
message to vt
explicitely, by adding the following at the end of osc7_cwd()
:
if [ -n "$TMUX" ]; then
printf '\e]7;file://%s%s\e\\' "${HOSTNAME%.lan}" "${encoded}" > `tmux display-message -p '#{client_tty}'`
fi
The full (confirmed to be working) strip from .bash_profile
:
osc7_cwd() {
local strlen=${#PWD}
local encoded=""
local pos c o
for (( pos=0; pos<strlen; pos++ )); do
c=${PWD:$pos:1}
case "$c" in
[-/:_.!\'\(\)~[:alnum:]] ) o="${c}" ;;
* ) printf -v o '%%%02X' "'${c}" ;;
esac
encoded+="${o}"
done
printf '\e]7;file://%s%s\e\\' "${HOSTNAME%.lan}" "${encoded}"
if [ -n "$TMUX" ]; then
printf '\e]7;file://%s%s\e\\' "${HOSTNAME%.lan}" "${encoded}" > `tmux display-message -p '#{client_tty}'`
fi
}
export PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }osc7_cwd