Categories
DailyOps

How to install cross-platform shell prompt

Install rust-powered customizable prompt for any shell (bash in my case).

Download recent release from GitHub.

$ wget https://github.com/starship/starship/releases/download/v1.3.0/starship-x86_64-unknown-linux-gnu.tar.gz \
       https://github.com/starship/starship/releases/download/v1.3.0/starship-x86_64-unknown-linux-gnu.tar.gz.sha256

Inspect file checksum.

$ cat starship-x86_64-unknown-linux-gnu.tar.gz.sha256 
d99fda409e1be96b07a8687bdbb1162e75c4a3c4301e7bf853dfd01dcb34a33d
$ shasum --algorithm 256 starship-x86_64-unknown-linux-gnu.tar.gz
d99fda409e1be96b07a8687bdbb1162e75c4a3c4301e7bf853dfd01dcb34a33d  starship-x86_64-unknown-linux-gnu.tar.gz

Inspect archive contents.

$ tar --list --verbose --gzip --file starship-x86_64-unknown-linux-gnu.tar.gz 
-rwxr-xr-x runner/docker 7097824 2022-02-07 16:04 starship

Extract released binary.

$ tar --extract --verbose --gzip --file starship-x86_64-unknown-linux-gnu.tar.gz starship

Move it into the PATH.

$ sudo mv starship /usr/local/bin/

Inspect starship version.

$ starship --version
starship 1.3.0

Inspect starship help.

$ starship help
starship 1.3.0
Starship Contributors
The cross-shell prompt for astronauts. โ˜„๐ŸŒŒ๏ธ

USAGE:
    starship 

OPTIONS:
    -h, --help       Print help information
    -V, --version    Print version information

SUBCOMMANDS:
    bug-report      Create a pre-populated GitHub issue with information about your
                    configuration
    completions     Generate starship shell completions for your shell to stdout
    config          Edit the starship configuration
    explain         Explains the currently showing modules
    help            Print this message or the help of the given subcommand(s)
    init            Prints the shell function used to execute starship
    module          Prints a specific prompt module
    print-config    Prints the computed starship configuration
    prompt          Prints the full starship prompt
    session         Generate random session key
    timings         Prints timings of all active modules
    toggle          Toggle a given starship module

Load bash shell completions.

$ eval "$(starship completions bash)"

Initialize starship.

$ eval "$(starship init bash)"

Ensure that these commands will be executed from personal initialization file.

โฏ cat <<EOF | tee --append ~/.bashrc
# starship - bash completions
eval "\$(starship completions bash)"

# starship - initialize
eval "\$(starship init bash)"
EOF

Store current configuration, so you can edit it later.

โฏ starship print-config | tee ~/.config/starship.toml
# Warning: This config does not include keys that have an unset value

# $all is shorthand for $username$hostname$localip$shlvl$singularity$kubernetes$directory$vcsh$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch$docker_context$package$cmake$cobol$dart$deno$dotnet$elixir$elm$erlang$golang$helm$java$julia$kotlin$lua$nim$nodejs$ocaml$perl$php$pulumi$purescript$python$rlang$red$ruby$rust$scala$swift$terraform$vlang$vagrant$zig$nix_shell$conda$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$battery$time$status$container$shell$character
format = '$all'
right_format = ''
continuation_prompt = '[โˆ™](bright-black) '
scan_timeout = 30
command_timeout = 500
add_newline = true

[aws]
format = 'on [$symbol($profile )(\($region\) )(\[$duration\])]($style)'
symbol = 'โ˜๏ธ  '
style = 'bold yellow'
disabled = false
expiration_symbol = 'X'

[aws.region_aliases]

[azure]
format = 'on [$symbol($subscription)]($style) '
symbol = '๏ดƒ '
style = 'blue bold'
disabled = true

[battery]
full_symbol = '๏•ธ '
charging_symbol = '๏–ƒ '
discharging_symbol = '๏–‚ '
unknown_symbol = '๏•ผ '
empty_symbol = '๏– '
disabled = false
format = '[$symbol$percentage]($style) '

[[battery.display]]
threshold = 10
style = 'red bold'

[character]
format = '$symbol '
success_symbol = '[โฏ](bold green)'
error_symbol = '[โฏ](bold red)'
vicmd_symbol = '[โฎ](bold green)'
disabled = false

[cmake]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = 'โ–ณ '
style = 'bold blue'
disabled = false
detect_extensions = []
detect_files = [
    'CMakeLists.txt',
    'CMakeCache.txt',
]
detect_folders = []

[cmd_duration]
min_time = 2000
format = 'took [$duration]($style) '
style = 'yellow bold'
show_milliseconds = false
disabled = false
show_notifications = false
min_time_to_notify = 45000

[cobol]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = 'โš™๏ธ '
style = 'bold blue'
disabled = false
detect_extensions = [
    'cbl',
    'cob',
    'CBL',
    'COB',
]
detect_files = []
detect_folders = []

[conda]
truncation_length = 1
format = 'via [$symbol$environment]($style) '
symbol = '๐Ÿ…’ '
style = 'green bold'
ignore_base = true
disabled = false

[container]
format = '[$symbol \[$name\]]($style) '
symbol = 'โฌข'
style = 'red bold dimmed'
disabled = false

[crystal]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿ”ฎ '
style = 'bold red'
disabled = false
detect_extensions = ['cr']
detect_files = ['shard.yml']
detect_folders = []

[dart]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐ŸŽฏ '
style = 'bold blue'
disabled = false
detect_extensions = ['dart']
detect_files = [
    'pubspec.yaml',
    'pubspec.yml',
    'pubspec.lock',
]
detect_folders = ['.dart_tool']

[deno]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿฆ• '
style = 'green bold'
disabled = false
detect_extensions = []
detect_files = [
    'deno.json',
    'deno.jsonc',
    'mod.ts',
    'deps.ts',
    'mod.js',
    'deps.js',
]
detect_folders = []

[directory]
truncation_length = 3
truncate_to_repo = true
fish_style_pwd_dir_length = 0
use_logical_path = true
format = '[$path]($style)[$read_only]($read_only_style) '
repo_root_format = '[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) '
style = 'cyan bold'
disabled = false
read_only = '๐Ÿ”’'
read_only_style = 'red'
truncation_symbol = ''
home_symbol = '~'
use_os_path_sep = true

[directory.substitutions]

[docker_context]
symbol = '๐Ÿณ '
style = 'blue bold'
format = 'via [$symbol$context]($style) '
only_with_files = true
disabled = false
detect_extensions = []
detect_files = [
    'docker-compose.yml',
    'docker-compose.yaml',
    'Dockerfile',
]
detect_folders = []

[dotnet]
format = 'via [$symbol($version )(๐ŸŽฏ $tfm )]($style)'
version_format = 'v${raw}'
symbol = '.NET '
style = 'blue bold'
heuristic = true
disabled = false
detect_extensions = [
    'csproj',
    'fsproj',
    'xproj',
]
detect_files = [
    'global.json',
    'project.json',
    'Directory.Build.props',
    'Directory.Build.targets',
    'Packages.props',
]
detect_folders = []

[elixir]
format = 'via [$symbol($version \(OTP $otp_version\) )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿ’ง '
style = 'bold purple'
disabled = false
detect_extensions = []
detect_files = ['mix.exs']
detect_folders = []

[elm]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐ŸŒณ '
style = 'cyan bold'
disabled = false
detect_extensions = ['elm']
detect_files = [
    'elm.json',
    'elm-package.json',
    '.elm-version',
]
detect_folders = ['elm-stuff']

[env_var]

[erlang]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๎žฑ '
style = 'bold red'
disabled = false
detect_extensions = []
detect_files = [
    'rebar.config',
    'erlang.mk',
]
detect_folders = []

[fill]
style = 'bold black'
symbol = '.'
disabled = false

[gcloud]
format = 'on [$symbol$account(@$domain)(\($region\))]($style) '
symbol = 'โ˜๏ธ  '
style = 'bold blue'
disabled = false

[gcloud.region_aliases]

[git_branch]
format = 'on [$symbol$branch]($style)(:[$remote]($style)) '
symbol = '๎‚  '
style = 'bold purple'
truncation_length = 9223372036854775807
truncation_symbol = 'โ€ฆ'
only_attached = false
always_show_remote = false
disabled = false

[git_commit]
commit_hash_length = 7
format = '[\($hash$tag\)]($style) '
style = 'green bold'
only_detached = true
disabled = false
tag_symbol = ' ๐Ÿท  '
tag_disabled = true

[git_metrics]
added_style = 'bold green'
deleted_style = 'bold red'
only_nonzero_diffs = true
format = '([+$added]($added_style) )([-$deleted]($deleted_style) )'
disabled = true

[git_state]
rebase = 'REBASING'
merge = 'MERGING'
revert = 'REVERTING'
cherry_pick = 'CHERRY-PICKING'
bisect = 'BISECTING'
am = 'AM'
am_or_rebase = 'AM/REBASE'
style = 'bold yellow'
format = '\([$state( $progress_current/$progress_total)]($style)\) '
disabled = false

[git_status]
format = '([\[$all_status$ahead_behind\]]($style) )'
style = 'red bold'
stashed = '\$'
ahead = 'โ‡ก'
behind = 'โ‡ฃ'
up_to_date = ''
diverged = 'โ‡•'
conflicted = '='
deleted = 'โœ˜'
renamed = 'ยป'
modified = '!'
staged = '+'
untracked = '?'
ignore_submodules = false
disabled = false

[golang]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿน '
style = 'bold cyan'
disabled = false
detect_extensions = ['go']
detect_files = [
    'go.mod',
    'go.sum',
    'glide.yaml',
    'Gopkg.yml',
    'Gopkg.lock',
    '.go-version',
]
detect_folders = ['Godeps']

[helm]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = 'โŽˆ '
style = 'bold white'
disabled = false
detect_extensions = []
detect_files = [
    'helmfile.yaml',
    'Chart.yaml',
]
detect_folders = []

[hg_branch]
symbol = '๎‚  '
style = 'bold purple'
format = 'on [$symbol$branch]($style) '
truncation_length = 9223372036854775807
truncation_symbol = 'โ€ฆ'
disabled = true

[hostname]
ssh_only = true
trim_at = '.'
format = '[$hostname]($style) in '
style = 'green dimmed bold'
disabled = false

[java]
disabled = false
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
style = 'red dimmed'
symbol = 'โ˜• '
detect_extensions = [
    'java',
    'class',
    'jar',
    'gradle',
    'clj',
    'cljc',
]
detect_files = [
    'pom.xml',
    'build.gradle.kts',
    'build.sbt',
    '.java-version',
    'deps.edn',
    'project.clj',
    'build.boot',
]
detect_folders = []

[jobs]
threshold = 1
symbol_threshold = 1
number_threshold = 2
format = '[$symbol$number]($style) '
symbol = 'โœฆ'
style = 'bold blue'
disabled = false

[julia]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = 'เฎƒ '
style = 'bold purple'
disabled = false
detect_extensions = ['jl']
detect_files = [
    'Project.toml',
    'Manifest.toml',
]
detect_folders = []

[kotlin]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿ…บ '
style = 'bold blue'
kotlin_binary = 'kotlin'
disabled = false
detect_extensions = [
    'kt',
    'kts',
]
detect_files = []
detect_folders = []

[kubernetes]
symbol = 'โ˜ธ '
format = '[$symbol$context( \($namespace\))]($style) in '
style = 'cyan bold'
disabled = true

[kubernetes.context_aliases]

[line_break]
disabled = false

[localip]
ssh_only = true
format = '[$localipv4]($style) '
style = 'yellow bold'
disabled = true

[lua]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐ŸŒ™ '
style = 'bold blue'
lua_binary = 'lua'
disabled = false
detect_extensions = ['lua']
detect_files = ['.lua-version']
detect_folders = ['lua']

[memory_usage]
threshold = 75
format = 'via $symbol[$ram( | $swap)]($style) '
style = 'white bold dimmed'
symbol = '๐Ÿ '
disabled = true

[nim]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿ‘‘ '
style = 'yellow bold'
disabled = false
detect_extensions = [
    'nim',
    'nims',
    'nimble',
]
detect_files = ['nim.cfg']
detect_folders = []

[nix_shell]
format = 'via [$symbol$state( \($name\))]($style) '
symbol = 'โ„๏ธ  '
style = 'bold blue'
impure_msg = 'impure'
pure_msg = 'pure'
disabled = false

[nodejs]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๎œ˜ '
style = 'bold green'
disabled = false
not_capable_style = 'bold red'
detect_extensions = [
    'js',
    'mjs',
    'cjs',
    'ts',
]
detect_files = [
    'package.json',
    '.node-version',
    '.nvmrc',
]
detect_folders = ['node_modules']

[ocaml]
format = 'via [$symbol($version )(\($switch_indicator$switch_name\) )]($style)'
version_format = 'v${raw}'
global_switch_indicator = ''
local_switch_indicator = '*'
symbol = '๐Ÿซ '
style = 'bold yellow'
disabled = false
detect_extensions = [
    'opam',
    'ml',
    'mli',
    're',
    'rei',
]
detect_files = [
    'dune',
    'dune-project',
    'jbuild',
    'jbuild-ignore',
    '.merlin',
]
detect_folders = [
    '_opam',
    'esy.lock',
]

[openstack]
format = 'on [$symbol$cloud(\($project\))]($style) '
symbol = 'โ˜๏ธ  '
style = 'bold yellow'
disabled = false

[package]
format = 'is [$symbol$version]($style) '
symbol = '๐Ÿ“ฆ '
style = '208 bold'
display_private = false
disabled = false
version_format = 'v${raw}'

[perl]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿช '
style = '149 bold'
disabled = false
detect_extensions = [
    'pl',
    'pm',
    'pod',
]
detect_files = [
    'Makefile.PL',
    'Build.PL',
    'cpanfile',
    'cpanfile.snapshot',
    'META.json',
    'META.yml',
    '.perl-version',
]
detect_folders = []

[php]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿ˜ '
style = '147 bold'
disabled = false
detect_extensions = ['php']
detect_files = [
    'composer.json',
    '.php-version',
]
detect_folders = []

[pulumi]
format = 'via [$symbol($username@)$stack]($style) '
version_format = 'v${raw}'
symbol = '๏†ฒ '
style = 'bold 5'
disabled = false

[purescript]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '<=> '
style = 'bold white'
disabled = false
detect_extensions = ['purs']
detect_files = ['spago.dhall']
detect_folders = []

[python]
pyenv_version_name = false
pyenv_prefix = 'pyenv '
python_binary = [
    'python',
    'python3',
    'python2',
]
format = 'via [${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)'
version_format = 'v${raw}'
style = 'yellow bold'
symbol = '๐Ÿ '
disabled = false
detect_extensions = ['py']
detect_files = [
    'requirements.txt',
    '.python-version',
    'pyproject.toml',
    'Pipfile',
    'tox.ini',
    'setup.py',
    '__init__.py',
]
detect_folders = []

[red]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿ”บ '
style = 'red bold'
disabled = false
detect_extensions = [
    'red',
    'reds',
]
detect_files = []
detect_folders = []

[rlang]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
style = 'blue bold'
symbol = '๐Ÿ“ '
disabled = false
detect_extensions = [
    'R',
    'Rd',
    'Rmd',
    'Rproj',
    'Rsx',
]
detect_files = ['.Rprofile']
detect_folders = ['.Rproj.user']

[ruby]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿ’Ž '
style = 'bold red'
disabled = false
detect_extensions = ['rb']
detect_files = [
    'Gemfile',
    '.ruby-version',
]
detect_folders = []
detect_variables = [
    'RUBY_VERSION',
    'RBENV_VERSION',
]

[rust]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿฆ€ '
style = 'bold red'
disabled = false
detect_extensions = ['rs']
detect_files = ['Cargo.toml']
detect_folders = []

[scala]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
disabled = false
style = 'red bold'
symbol = '๐Ÿ†‚ '
detect_extensions = [
    'sbt',
    'scala',
]
detect_files = [
    '.scalaenv',
    '.sbtenv',
    'build.sbt',
]
detect_folders = ['.metals']

[shell]
format = '[$indicator]($style) '
bash_indicator = 'bsh'
fish_indicator = 'fsh'
zsh_indicator = 'zsh'
powershell_indicator = 'psh'
ion_indicator = 'ion'
elvish_indicator = 'esh'
tcsh_indicator = 'tsh'
nu_indicator = 'nu'
xonsh_indicator = 'xsh'
cmd_indicator = 'cmd'
unknown_indicator = ''
style = 'white bold'
disabled = true

[shlvl]
threshold = 2
format = '[$symbol$shlvl]($style) '
symbol = 'โ†•๏ธ  '
repeat = false
style = 'bold yellow'
disabled = true

[singularity]
symbol = ''
format = '[$symbol\[$env\]]($style) '
style = 'blue bold dimmed'
disabled = false

[status]
format = '[$symbol$status]($style) '
symbol = 'โœ–'
success_symbol = 'โœ”๏ธ'
not_executable_symbol = '๐Ÿšซ'
not_found_symbol = '๐Ÿ”'
sigint_symbol = '๐Ÿงฑ'
signal_symbol = 'โšก'
style = 'bold red'
map_symbol = false
recognize_signal_code = true
pipestatus = false
pipestatus_separator = '|'
pipestatus_format = '\[$pipestatus\] => [$symbol$common_meaning$signal_name$maybe_int]($style)'
disabled = true

[sudo]
format = '[as $symbol]($style)'
symbol = '๐Ÿง™ '
style = 'bold blue'
allow_windows = false
disabled = true

[swift]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = '๐Ÿฆ '
style = 'bold 202'
disabled = false
detect_extensions = ['swift']
detect_files = ['Package.swift']
detect_folders = []

[terraform]
format = 'via [$symbol$workspace]($style) '
version_format = 'v${raw}'
symbol = '๐Ÿ’  '
style = 'bold 105'
disabled = false
detect_extensions = [
    'tf',
    'tfplan',
    'tfstate',
]
detect_files = []
detect_folders = ['.terraform']

[time]
format = 'at [$time]($style) '
style = 'bold yellow'
use_12hr = false
disabled = true
utc_time_offset = 'local'
time_range = '-'

[username]
format = '[$user]($style) in '
style_root = 'red bold'
style_user = 'yellow bold'
show_always = false
disabled = false

[vagrant]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = 'โฑ '
style = 'cyan bold'
disabled = false
detect_extensions = []
detect_files = ['Vagrantfile']
detect_folders = []

[vcsh]
symbol = ''
style = 'bold yellow'
format = 'vcsh [$symbol$repo]($style) '
disabled = false

[vlang]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = 'V '
style = 'blue bold'
disabled = false
detect_extensions = ['v']
detect_files = [
    'v.mod',
    'vpkg.json',
    '.vpkg-lock.json',
]
detect_folders = []

[zig]
format = 'via [$symbol($version )]($style)'
version_format = 'v${raw}'
symbol = 'โ†ฏ '
style = 'bold yellow'
disabled = false
detect_extensions = ['zig']
detect_files = []
detect_folders = []

[custom]

Visit project website starship.rs or GitHub repository starship/starship for more details.

Play with it and have a nice day!