Using Elvish as your default shell

Table of content

Configuring the terminal to run Elvish

This is the recommended way to use Elvish as your default shell.

macOS terminals

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

Linux and BSD terminals

Terminal Instructions
GNOME Terminal
  1. Open Edit > Preferences.
  2. In the right-hand panel, select the Command tab.
  3. Tick Run a custom command instead of my shell, and set Custom command to the path to Elvish.
Konsole
  1. Open Settings > Edit Current Profile.
  2. Set Command to the path to Elvish.
XFCE Terminal
  1. Open Edit > Preferences.
  2. Tick 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 to change the shell. Depending on your DE, you can either create a wrapper script or modify the desktop file:

Terminal Instructions
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
  1. Press Ctrl+, to open Settings.
  2. Select Add a new profile from the left sidebar, and click New empty profile.
  3. Set Name to “Elvish” and Command line to the path to Elvish.
  4. Select Startup from the left sidebar, and set Default profile to Elvish.
  5. Hit Save.
ConEmu
  1. Press Win+Alt+T to open Startup Tasks.
  2. Click ± below the list of existing tasks.
  3. Set the name to “Elvish”, enter the path to Elvish in the textbox below Commands, and tick Default task for new console.
  4. Click Save settings.

VS Code

Open the command palette and run “Open User Settings (JSON)”. Add the following:

    "terminal.integrated.defaultProfile.linux": "elvish",
    "terminal.integrated.profiles.linux": {
        "elvish": {
            "path": "elvish"
        },
    }

Change linux to osx or windows depending on your operating system. See VS Code’s documentation for more details.

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 invoke the user’s login shell assuming that it is a traditional POSIX-like shell, so they may not work correctly if your login shell is Elvish. The following programs have been reported to have issues:

  • GDB (see #1795)

  • The vscode-neovim extension (see #1804)

Such programs usually rely on the $SHELL environment variable to query the login shell. For CLI applications, you can create an alias in your rc.elv that forces it to a POSIX shell, like the following:

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

There is no universal way to override environment variables for GUI applications; it depends on the GUI environment and possibly the application itself. It may be easier to switch the login shell back to the system default and configure your terminal to launch Elvish.