sl-site/tips/starship.md

1.9 KiB

title date description
Starship Prompt 2021-04-05 Pimp your shell prompt!

Starship is an awesome little program that makes your shell look much cooler without much effort.

Install

As we are working on a pubnix, we can't install things globally so instead of following the instructions on the Starship site follow these instead.

First up, we need to make somewhere to install our local programs, so let's make a folder for that at ~/.local/bin.

mkdir -p ~/.local/bin

Now we can download the Starship install script like so.

wget https://starship.rs/install.sh

Before we use this script, we should inspect it to make sure nothing nasty is happening. After doing that, we can set the permissions on it so that we can run it and install it to our new bin folder.

chmod +x ./install.sh
./install.sh --bin-dir ~/.local/bin

Finally, we need to tell our shell to load this prompt and where we have our local programs, so we can do that by adding the following lines to the bottom of your ~/.bashrc file like so.

# other stuff...

export PATH="${PATH}:~/.local/bin"

eval "$(starship init bash)"

Now you can either logout and back in to see the changes, or you can run source ~/.bashrc.

Customize

Starship makes a big difference by itself, but I like to turn off some of the fancy features and change the settings slightly to keep it minimal. You can do this by editing the file at ~/.config/starship.toml. You can see all of the configuration options here, but this is what I like:

add_newline = false
format = """$username\
$hostname\
$directory\
$git_branch\
$git_commit\
$git_state\
$git_status\
$character
"""

[character]
success_symbol = "[➜](bold green)"
error_symbol = "[➜](bold red)"

[username]
format = "[$user]($style)"

[hostname]
format = ":[$hostname]($style) "