Shells

Bash

Multi-line prompts

When you press RET on an incomplete command, bash has the annoying habit of starting a secondary prompt which doesn’t let you go back to the previous line with the default keybindings.

To work around that, type S-<return> instead of RET while on the terminal zone of a MisTTY buffer. This sends a newline without running the command. You’ll then end up with one multi-line prompt that you can edit normally.

You’ll get the same effect if you yank a multi-line command while in a prompt or go up the command history to a previous multi-line command.

Directory tracking

Recent versions of bash already send the current directory when they detects that it’s called from Emacs with TERM=eterm-color, so as long as you don’t want TRAMP remote paths, you don’t have to do anything.

If you do want to use TRAMP remote paths, extend your prompt to send out an OSC7 sequence to have bash send the current directory and hostname to MisTTY.

To do that, you might add the following to ~/.bashrc:

if [ "$TERM" = "eterm-color" ]; then
  PS1='\e]7;file://$HOSTNAME$PWD\e\\\\'$PS1
fi

Such sequence are either ignored or understood by most terminals, so you don’t absolutely need to check TERM.

VI mode

To communicate with bash, MisTTY requires the shell to be in its default editing mode, that is, the emacs mode. Please make sure you haven’t put readline or bash in vi mode before trying out MisTTY.

To turn on vi mode in readline everywhere but MisTTY, you can add something like the following into ~/.inputrc:

$if term=eterm
  set editing-mode emacs
$else
  set editing-mode vi
$endif

Or, in bash ~/.bashrc:

if [ "$TERM" != "eterm-color" ]; then
  set -o vi
fi

Fish

Autosuggestions

fish autosuggestions work normally in MisTTY. However, the usual way of accepting an autosuggestion, pressing the right arrow key, is very inconvenient as this is bound to an Emacs point movement.

The recommended way of accepting an autosuggestion in MisTTY is to type C-e. This works in normal terminals as well.

Command History

To make full use of fish command history, you’ll want to forward some additional shortcuts to fish:

(keymap-set mistty-prompt-map "M-<up>" #'mistty-send-key)
(keymap-set mistty-prompt-map "M-<down>" #'mistty-send-key)
(keymap-set mistty-prompt-map "M-<left>" #'mistty-send-key)
(keymap-set mistty-prompt-map "M-<right>" #'mistty-send-key)

This can also be done by calling use-package as shown in Installation.

When in reverse history search mode, fish enters a mode that lets you select an option using the arrow keys. To send up/down/left/right directly to fish, you can:

  • use M-p to go up and M-n to go down, or, if you prefer

  • use C-q <up> C-q <down> C-q <left> C-q <right>, or even

  • C-c C-q to temporarily send all send key presses to fish

Directory tracking

Extend your prompt to send out an OSC7 sequence to have fish send the current directory and hostname to MisTTY. To do that, you might add the following to ~/.local/config/fish/config.fish:

if [ "$TERM" = "eterm-color" ]
  function osc7_send_pwd --on-event fish_prompt
    printf "\e]7;file://%s%s\e\\\\" (hostname) "$PWD"
  end
end

such sequence are either ignored or understood by most terminals. You might already have it set up.

Multi-line prompts

fish automatically detects when a command is incomplete when you type RET and launches a multi-line prompt, which MisTTY knows to navigate.

The cursor jumps over indent space while on such a prompt, just like in a normal terminal. M-x customize-option mistty-skip-empty-spaces allows you to turn that on or off in a MisTTY buffer.

VI mode

To communicate with fish, MisTTY requires the shell to be in its default editing mode, that is, the emacs mode. Please make sure you haven’t put readline or bash in vi mode before trying out MisTTY.

To turn on vi mode in readline everywhere but in MisTTY, you can add something like the following in ~/.zshrc:

if [ "$TERM" != "eterm-color" ]
  fish_vi_key_bindings
end

Zsh

Autosuggestions

Fish-like zsh autosuggestions work normally in MisTTY, if you’ve turned these on. However, the usual way of accepting an autosuggestion, pressing the right arrow key, is very inconvenient as this is normally bound to an Emacs point movement.

The recommended way of accepting an autosuggestion in MisTTY is to type C-e. This works in normal terminals as well.

Directory tracking

Extend your prompt to send out an OSC7 sequence to have zsh send the current directory and hostname to MisTTY. To do that, you might add the following to ~/.zshrc:

if [ "$TERM" != "eterm-color" ]; then
    PS1='\e]7;file://$HOSTNAME$PWD\e\\\\'$PS1
fi

such sequence are either ignored or understood by most terminals.

Multi-line prompts

When you press RET on an incomplete command, zsh has the annoying habit of starting a secondary prompt. MisTTY doesn’t know how to go back to the previous prompt from such a prompt.

To work around that, type S-<return> instead of RET while on the terminal zone of a MisTTY buffer. This sends a newline without running the command. You’ll then end up with one multi-line prompt that you can edit normally.

You’ll get the same effect if you yank a multi-line command while in a prompt or go up the command history to a previous multi-line command.

VI mode

To communicate with zsh, MisTTY requires the shell to be in its default editing mode, that is, the emacs mode. Please make sure you haven’t put readline or bash in vi mode before trying out MisTTY.

To turn on vi mode in readline everywhere but in MisTTY, you can add something like the following in ~/.zshrc:

if [ "$TERM" != "eterm-color" ]; then
  bindkey -v
fi