1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-10 15:20:55 +00:00
The minimal, blazing-fast, and infinitely customizable prompt for any shell!
Go to file
Daniel Watkins 1a72757f01
fix: combine ANSI color codes before wrapping them (#5762)
* combine ANSI color codes before wrapping them

The existing code wraps each individual module's output for
`context.shell`, concatenates all that output together and passes it to
`AnsiStrings` to merge ANSI color codes.  However, the wrapping obscures
ANSI color codes, meaning that no merging is possible.

This commit changes the shell-specific wrapping to happen right before
output, once all modules' output has been concatenated together.  This
results in ANSI color codes being correctly merged, as well as reducing
the number of calls to `wrap_colorseq_for_shell` to one.

With a minimal `starship.toml`:

```
format = """$directory"""

[directory]
format = '[a]($style)[b]($style)'
```

The current code produces[0]:

```
\n%{\x1b[31m%}a%{\x1b[0m%}%{\x1b[31m%}b%{\x1b[0m%
```

And this commit's code:

```
\n%{\x1b[31m%}ab%{\x1b[0m%}
```

You can see that the current code emits an additional reset and repeated
color code between "a" and "b" compared to the new code.

[0] Produced in a Python shell with:

```
subprocess.check_output(
    "./target/debug/starship prompt", shell=True,
    env={"STARSHIP_CONFIG": "./starship.toml", "STARSHIP_SHELL": "zsh"}
)
```

* utils: return early from wrap_seq_for_shell unless wrapping required

* refactor(utils): simplify wrap_seq_for_shell

This commit modifies wrap_seq_for_shell to (a) return early for shells
with no wrapping required, and (b) determine the wrapping characters
once at the start of the function (rather than inline in the map
function for every character).
2024-04-06 15:28:26 +02:00
.github feat(username): add aliases option (#5855) 2024-04-05 23:57:13 +02:00
docs feat(username): add aliases option (#5855) 2024-04-05 23:57:13 +02:00
install fix: replace all remaining paths referring to vuepress (#5859) 2024-03-24 08:03:55 +01:00
media docs: add Ukranian to the project README (#5147) 2023-04-28 23:07:35 +09:00
src fix: combine ANSI color codes before wrapping them (#5762) 2024-04-06 15:28:26 +02:00
.codecov.yml ci: add test coverage reporting with codecov (#3848) 2022-04-08 20:20:24 -04:00
.dprint.json fix: replace all remaining paths referring to vuepress (#5859) 2024-03-24 08:03:55 +01:00
.gitattributes revert(schema): move config-schema back into .github folder (#3886) 2022-04-18 17:42:47 +02:00
.gitignore feat(docs): move to vitepress (#5785) 2024-03-03 17:55:30 +01:00
.rustfmt.toml style: make rustfmt use the default configuration (#1661) 2020-09-19 08:45:17 +02:00
build.rs feat(docs): move to vitepress (#5785) 2024-03-03 17:55:30 +01:00
Cargo.lock build(deps): update rust crate notify-rust to 4.11.0 2024-04-04 23:55:01 +00:00
Cargo.toml build(deps): update rust crate notify-rust to 4.11.0 2024-04-04 23:55:01 +00:00
CHANGELOG.md chore(master): release 1.18.2 (#5882) 2024-03-29 16:41:58 +01:00
clippy.toml fix(windows): avoid verbatim paths (#3638) 2022-02-23 18:32:35 -05:00
CODE_OF_CONDUCT.md ci: Use dprint to format documentation + TOML files (#3426) 2022-01-20 11:32:09 +03:00
CONTRIBUTING.md feat(docs): move to vitepress (#5785) 2024-03-03 17:55:30 +01:00
crowdin.yml chore: update Crowdin PR title 2021-01-29 16:53:32 -05:00
deny.toml chore(cargo-deny): migrate to advisories & licenses v2 config (#5877) 2024-03-29 16:40:58 +01:00
LICENSE chore: Update LICENSE file for 2022 (#3514) 2022-01-25 21:09:06 -06:00
README.md Update sponsors 2024-03-21 15:45:06 +09:00
release-please-config.json ci: update release-please to v4 (#5619) 2023-12-09 14:06:34 +01:00
starship.exe.manifest feat: Add a Windows application manifest (#3590) 2022-02-20 18:12:40 +01:00
typos.toml chore: fix typos (#5239) 2023-06-13 15:40:17 -05:00

Starship – Cross-shell prompt

GitHub Actions workflow status Crates.io version Packaging status
Chat on Discord Follow @StarshipPrompt on Twitter Stand With Ukraine

Website · Installation · Configuration

English   Deutsch   Español   Français   Bahasa Indonesia   Italiano   日本語   Português do Brasil   Русский   Українська   Tiếng Việt   简体中文   繁體中文

Starship with iTerm2 and the Snazzy theme

The minimal, blazing-fast, and infinitely customizable prompt for any shell!

  • Fast: it's fast really really fast! 🚀
  • Customizable: configure every aspect of your prompt.
  • Universal: works on any shell, on any operating system.
  • Intelligent: shows relevant information at a glance.
  • Feature rich: support for all your favorite tools.
  • Easy: quick to install  start using it in minutes.

Explore the Starship docs  ▶

🚀 Installation

Prerequisites

Step 1. Install Starship

Select your operating system from the list below to view installation instructions:

Android

Install Starship using any of the following package managers:

Repository Instructions
Termux pkg install starship
BSD

Install Starship using any of the following package managers:

Distribution Repository Instructions
Any crates.io cargo install starship --locked
FreeBSD FreshPorts pkg install starship
NetBSD pkgsrc pkgin install starship
Linux

Install the latest version for your system:

curl -sS https://starship.rs/install.sh | sh

Alternatively, install Starship using any of the following package managers:

Distribution Repository Instructions
Any crates.io cargo install starship --locked
Any conda-forge conda install -c conda-forge starship
Any Linuxbrew brew install starship
Alpine Linux 3.13+ Alpine Linux Packages apk add starship
Arch Linux Arch Linux Extra pacman -S starship
CentOS 7+ Copr dnf copr enable atim/starship
dnf install starship
Gentoo Gentoo Packages emerge app-shells/starship
Manjaro pacman -S starship
NixOS nixpkgs nix-env -iA nixpkgs.starship
openSUSE OSS zypper in starship
Void Linux Void Linux Packages xbps-install -S starship
macOS

Install the latest version for your system:

curl -sS https://starship.rs/install.sh | sh

Alternatively, install Starship using any of the following package managers:

Repository Instructions
crates.io cargo install starship --locked
conda-forge conda install -c conda-forge starship
Homebrew brew install starship
MacPorts port install starship
Windows

Install the latest version for your system with the MSI-installers from the releases section.

Install Starship using any of the following package managers:

Repository Instructions
crates.io cargo install starship --locked
Chocolatey choco install starship
conda-forge conda install -c conda-forge starship
Scoop scoop install starship
winget winget install --id Starship.Starship

Step 2. Set up your shell to use Starship

Configure your shell to initialize starship. Select yours from the list below:

Bash

Add the following to the end of ~/.bashrc:

eval "$(starship init bash)"
Cmd

You need to use Clink (v1.2.30+) with Cmd. Create a file at this path %LocalAppData%\clink\starship.lua with the following contents:

load(io.popen('starship init cmd'):read("*a"))()
Elvish

Add the following to the end of ~/.elvish/rc.elv:

eval (starship init elvish)

Note: Only Elvish v0.18+ is supported

Fish

Add the following to the end of ~/.config/fish/config.fish:

starship init fish | source
Ion

Add the following to the end of ~/.config/ion/initrc:

eval $(starship init ion)
Nushell

Add the following to the end of your Nushell env file (find it by running $nu.env-path in Nushell):

mkdir ~/.cache/starship
starship init nu | save -f ~/.cache/starship/init.nu

And add the following to the end of your Nushell configuration (find it by running $nu.config-path):

use ~/.cache/starship/init.nu

Note: Only Nushell v0.78+ is supported

PowerShell

Add the following to the end of your PowerShell configuration (find it by running $PROFILE):

Invoke-Expression (&starship init powershell)
Tcsh

Add the following to the end of ~/.tcshrc:

eval `starship init tcsh`
Xonsh

Add the following to the end of ~/.xonshrc:

execx($(starship init xonsh))
Zsh

Add the following to the end of ~/.zshrc:

eval "$(starship init zsh)"

Step 3. Configure Starship

Start a new shell instance, and you should see your beautiful new shell prompt. If you're happy with the defaults, enjoy!

If you're looking to further customize Starship:

  • Configuration learn how to configure Starship to tweak your prompt to your liking

  • Presets get inspired by the pre-built configuration of others

🤝 Contributing

We are always looking for contributors of all skill levels! If you're looking to ease your way into the project, try out a good first issue.

If you are fluent in a non-English language, we greatly appreciate any help keeping our docs translated and up-to-date in other languages. If you would like to help, translations can be contributed on the Starship Crowdin.

If you are interested in helping contribute to starship, please take a look at our Contributing Guide. Also, feel free to drop into our Discord server and say hi. 👋

💭 Inspired By

Please check out these previous works that helped inspire the creation of starship. 🙏

❤️ Sponsors

Support this project by becoming a sponsor. Your name or logo will show up here with a link to your website.


Starship rocket icon

📝 License

Copyright © 2019-present, Starship Contributors.
This project is ISC licensed.