Starship Prompt¶
Prerequisites
- Install Starship Prompt from official documentation.
- Setup your shell (
bash
,zsh
orfish
) to use Starship from official documentation
Note
- I am using MacOS. So, for other OS the paths may differ.
- I have used Nerd Fonts thats why there are some
symbol
which may not appear as they are. - I have defined some conventions to define my
starship.toml
file. If you want to know them read the sections where I describe my conventions.
Customization¶
You can customize your prompt for each programming languages you uses like Python, JavaScript, Rust and more. See official documentation to know more.
Example: Python¶
[python]
symbol = "î" # (1)!
style = "arv_python"
format = "[î¶](fg:$style)[$symbol( $version)[( \\($virtualenv\\))](bold bg:$style)](bg:$style)[îŽ](fg:$style)"
Example: Docker¶
[docker_context]
symbol = "ï" # (1)!
style = "arv_docker"
format = "[î¶](fg:$style)[$symbol ($context)](bg:$style)[îŽ](fg:$style)"
Conventions
- Enclosed Modules: Each modules enclose with circular end.
Color Palette¶
Did you see style = "arv_python"
and style = "arv_docker"
in above examples.
Those are my custom defined palette as "arv-anshul"
.
palette = "arv-anshul"
[palettes.arv-anshul]
arv_dir = "203"
arv_docker = "026"
arv_git = "063"
arv_python = "028"
arv_custom = "236"
Print ANSI Colormap
If you doc't want to use ANSI color format then you also use starship
's pre-defined colors: black
, red
, green
, blue
, yellow
, purple
, cyan
, white
. You can optionally prefix these with bright-
to get the bright version (e.g. bright-white
). See in documentation
palette = "arv-anshul-color"
[palettes.arv-anshul-color]
arv_dir = "bright-red"
arv_docker = "bright-blue"
arv_git = "blue"
arv_python = "green"
arv_custom = "black"
Conventions
- Palette Preffix: Palette's
keys
must have a preffix (in my case it is"arv_"
). - ANSI Codes: I have defined colors in ANSI Codes. See this Gist to know more about ANSI Codes.
- Own Color Palette: I have defined programming language-wise (or module-wise) colors which makes easy to change/manipulate the color of any language.
You can also create your own custom color palette in
~/.config/starship.toml
.
Extra customization with custom modules¶
[custom.github]
detect_folders = [".github"]
format = "[$symbol]($style)"
style = "bg:arv_custom"
symbol = "îȘ " # (1)!
[custom.mkdocs]
detect_files = ["mkdocs.yaml", "mkdocs.yml"]
detect_folders = ["docs"]
format = "[$symbol]($style)"
style = "bg:arv_custom"
symbol = "ó± " # (2)!
[custom.vscode]
detect_folders = [".vscode"]
format = "[$symbol]($style)"
style = "bg:arv_custom"
symbol = "ó°š " # (3)!
Conventions
I have used custom
modules to just show some desirable icons in the prompt but you can do a lot of thing using custom
modules (the possibilities are endless).
- Show Custom Icons: I used
custom
modules to show icons by detecting files and folders. For example, prompt will show icons when.github
folder is present in the current directory.
Refer to official documentation to know more about custom modules.
Tip
From official documentation
Issue #1252 contains examples of custom
modules. You can go there for inspiration and if you have an interesting example not covered there, feel free to share it there!