Skip to content

Shell working directory reporting

Eugeny edited this page May 6, 2022 · 7 revisions

Rationale

With remote shells and WSL, there is no reliable way for a host terminal to determine the shell's working directory. The same also applies when using GNU Screen and tmux.

Tabby allows shells to report their CWD using the OSC 1337 protocol, originally implemented by iTerm.

This allows following:

  • "Copy current path" context/tab menu item to work
  • SFTP panel to open in the shell's current directory
  • Same for WinSCP

To enable this, add following to your remote shell's profile file and restart the shell / re-login:

Bash

~/.bash_profile:

export PS1="$PS1\[\e]1337;CurrentDir="'$(pwd)\a\]'

ZSH

~/.zshrc:

precmd () { echo -n "\x1b]1337;CurrentDir=$(pwd)\x07" }

Fish

~/.config/fish/config.fish:

function __tabby_working_directory_reporting --on-event fish_prompt
    echo -en "\e]1337;CurrentDir=$PWD\x7"
end