LinuxCommandLibrary

starship-init

Initialize Starship prompt in your shell

TLDR

Print the starship integration code for the specified shell

$ starship init [bash|elvish|fish|ion|powershell|tcsh|zsh]
copy

Append the starship integration code to ~/.bashrc
$ starship init [bash] >> [~/.bashrc]
copy

Append the starship integration code to ~/.zshrc
$ starship init [zsh] >> [~/.zshrc]
copy

Display help
$ starship init --help
copy

SYNOPSIS

starship init [SHELL]

PARAMETERS

SHELL
    The shell to generate the initialization code for. Supported shells include bash, zsh, fish, powershell, elvish, xonsh, cmd, nu, ion.

DESCRIPTION

The `starship-init` command is crucial for integrating the Starship cross-shell prompt with your chosen shell environment. It generates the necessary shell code that configures Starship to function correctly. This code is then evaluated by your shell startup scripts (e.g., `.bashrc`, `.zshrc`, `config.fish`) allowing Starship to dynamically display information such as the current directory, Git status, programming language versions, and other relevant context, enhancing the terminal experience.
The specific code generated depends on the target shell specified as an argument. Without proper initialization, Starship won't activate or display the custom prompt. Think of `starship-init` as the bridge connecting Starship's core functionality to your shell's user interface. It is essential for customization and correct display of terminal prompts by fetching info from various services on the current system.

CAVEATS

The output of `starship init` must be evaluated by your shell to take effect. Typically, this is done by adding `eval "$(starship init [SHELL])"` to your shell's configuration file.

EXAMPLE USAGE

To initialize Starship for Zsh, add the following line to your `~/.zshrc` file:
eval "$(starship init zsh)"
After adding the command make sure to execute source ~/.zshrc or restart the current shell.

CONFIGURATION

Starship's behavior is highly configurable through a `starship.toml` file. `starship-init` itself does not handle configuration directly; it only provides the initialization code. Configuration lives elsewhere.

HISTORY

Starship is a relatively modern, highly customizable prompt designed to improve developer productivity. `starship-init` is integral to Starship's design, allowing for cross-shell compatibility without requiring extensive shell-specific configuration.

SEE ALSO

Copied to clipboard