Skip to content

Shell integration

The integration is a short script per shell that reports prompts, commands, exit codes, the working directory and the host. What it enables is on the feature page.

Welcome screen › Install shell integration, or Ubiquitty › Install Shell Integration…. It asks first and names the files. It adds this block to ~/.zshrc and ~/.bashrc, and to ~/.bash_profile and ~/.config/fish/config.fish if you have them:

Terminal window
# >>> Ubiquitty shell integration >>>
# Loads Ubiquitty's shell integration in the shells Ubiquitty starts.
# Remove this block to undo.
if [[ -n "${UBIQUITTY_INTEGRATION_DIR-}" && -r "$UBIQUITTY_INTEGRATION_DIR/zsh.sh" ]]; then
source "$UBIQUITTY_INTEGRATION_DIR/zsh.sh"
fi
# <<< Ubiquitty shell integration <<<

A missing ~/.zshrc or ~/.bashrc is created; a missing ~/.bash_profile is not, because creating one would stop a login bash from reading ~/.profile. Running the installer again rewrites the block in place. A startup file that is a symbolic link into a dotfiles repository stays a link; the block goes into the file it points to.

To do it by hand:

~/.zshrc
[ -n "$UBIQUITTY_INTEGRATION_DIR" ] && source "$UBIQUITTY_INTEGRATION_DIR/zsh.sh"
# ~/.bashrc
[ -n "$UBIQUITTY_INTEGRATION_DIR" ] && source "$UBIQUITTY_INTEGRATION_DIR/bash.sh"
# ~/.config/fish/config.fish
test -n "$UBIQUITTY_INTEGRATION_DIR" && source "$UBIQUITTY_INTEGRATION_DIR/fish.fish"

Ubiquitty sets UBIQUITTY_INTEGRATION_DIR in every shell it starts.

Install it on every machine you ssh to. A local terminal sees one ssh process however many hops there are; a shell on the far end reporting its own host is the only way to know where a session really is.

Terminal window
scp "$UBIQUITTY_INTEGRATION_DIR/zsh.sh" example-host:~/.ubiquitty-zsh.sh
ssh example-host 'echo "source ~/.ubiquitty-zsh.sh" >> ~/.zshrc'

Source it unconditionally. Do not test TERM_PROGRAM: it does not cross ssh unless both ends configure SendEnv and AcceptEnv. The script sends only standard sequences, which a terminal that does not read them ignores.

If the remote host does not recognise the terminal type, File › Set Up Ubiquitty on Remote Host… gives a copy-and-paste command that installs the xterm-ubiquitty terminfo entry there.

~/.zshrc
eval "$(ubq completions zsh)"
# ~/.bashrc
eval "$(ubq completions bash)"

ubq completes its verbs, flags and the host’s live session ids.