Using Elvish as your default shell

Table of content

Configuring the terminal to run Elvish

The recommended way to use Elvish as your default shell is to configure your terminal to launch Elvish as the default command for new sessions.

macOS terminals

Terminal Instructions
Terminal.app Open Terminal > Preferences. Ensure you are on the Profiles tab, which should be the default tab. In the right-hand panel, select the Shell tab. Tick Run command, put the path to Elvish in the textbox, and untick Run inside shell.
iTerm2 Open iTerm > Preferences. Select the Profiles tab. In the right-hand panel under Command, change the dropdown from Login Shell to Custom Shell, and put the path to Elvish in the textbox.

Linux and BSD terminals

Terminal Instructions
GNOME Terminal Open Edit > Preferences. In the right-hand panel, select the Command tab, tick Run a custom command instead of my shell, and set Custom command to the path to Elvish.
Konsole Open Settings > Edit Current Profile. Set Command to the path to Elvish.
XFCE Terminal Open Edit > Preferences. Check Run a custom command instead of my shell, and set Custom command to the path to Elvish.
The following terminals only support a command-line flag for changing the shell
LXTerminal Pass --command $path_to_elvish.
rxvt Pass -e $path_to_elvish.
xterm Pass -e $path_to_elvish.

tmux

Add the following to ~/.tmux.conf:

if-shell 'which elvish' 'set -g default-command elvish'

This only launches Elvish if it’s available, so it’s safe to have in a .tmux.conf that you sync with machines where you haven’t installed Elvish yet.

Windows terminals

Terminal Instructions
Windows Terminal Press Ctrl+, to open Settings. Go to Add a new profile > New empty profile. Fill in the 'Name' and enter path to Elvish in the 'Command line' textbox. Go to Startup option and select Elvish as the 'Default profile'. Hit Save.
ConEmu Press Win+Alt+ T to open the Startup Tasks dialog. Click on ± button to create a new task, give it Elvish alias, enter the path to Elvish in the 'Commands' textbox and tick the 'Default task for new console' checkbox. Click on Save settings to finish.

Changing your login shell

On Unix systems, you can also use Elvish as your login shell. Run the following Elvish snippet:

use runtime
if (not (has-value [(cat /etc/shells)] $runtime:elvish-path)) {
    echo $runtime:elvish-path | sudo tee -a /etc/shells
}
chsh -s $runtime:elvish-path

You can change your login shell back to the system default with chsh -s ''.

Dealing with incompatible programs

Some programs assume that the user’s login shell is a traditional POSIX-like shell, so they won’t work correctly if your login shell is Elvish. The following programs are known to have issues:

Such programs usually rely on the $SHELL environment variable to query the login shell, so you can override it to a POSIX shell, like the following:

fn gdb {|@a|
  env SHELL=/bin/sh gdb $@
}