Skip to content
NNB edited this page Apr 14, 2022 · 13 revisions

Starship copycat

Quick guide on recreate Starship's modules

πŸ’‘ About

This guide will show you how to recreate any Starship's modules ordered by category.

This guide is currently based on Starship v1.0.0 (2021-11-09).

πŸ”° Basic

Because nearly all programing languages have an ability to get environment variables and output string, you can recreate the following modules with your favorite programing language/shell:

Module Shell script
Custom commands Custom commands
Directory printf "$PWD"
Environment Variable printf "$some_variable"
Line Break printf "\n"
SHLVL printf "$SHLVL"

Displaying current directory in shell script can be enhanced with path_prettier.

🐚 Shell specific features

You can utilize DIYship exported environment variables to recreate the following modules:

Module Environment variable
Character $DIYSHIP_STATUS and $DIYSHIP_KEYMAP
Command Duration $DIYSHIP_DURATION
Jobs $DIYSHIP_JOBS
Shell $DIYSHIP_SHELL
Status $DIYSHIP_STATUS, $DIYSHIP_PIPESTATUS

Displaying command duration and status in shell script can be enhanced with ms2duration and status2signal.

πŸ–₯️️ System informations

Module Shell script
Battery cat /sys/class/power_supply/BAT1/capacity, cat /sys/class/power_supply/BAT1/status (sometime BAT0)
Hostname hostname
Memory Usage cat /proc/meminfo
Time date
Username whoami, printf "$USER"

Displaying battery level in shell script can be enhanced with battery-level-cli.

πŸ”Ά Git informations

Module Shell script
Git Branch git rev-parse --abbrev-ref HEAD
Git Commit git rev-parse --verify --short HEAD, git tag --points-at HEAD
Git State #TODO
Git Metrics git diff --shortstat
Git Status git status --porcelain -b 2> /dev/null ...

πŸ‡» Programs version

Check out asdf for manage multiple runtime versions.

Module Shell script
CMake cmake --version | head -n '1' | cut -d ' ' -f '3'
COBOL/GNUCOBOL cobc -version | head -n '1' | cut -d ' ' -f '3'
Crystal crystal version | head -n '1' | cut -d ' ' -f '2'
Dart dart --version 2>&1 | cut -d ' ' -f '4'
Deno deno eval 'console.log(Deno.version.deno)'
Elixir elixir -e 'IO.write System.version'
Elm elm --version
Erlang erl -noshell -eval 'io:format(erlang:system_info(otp_release)), halt().'
Golang go version | tr -dc ' .[:digit:]' | cut -d ' ' -f '3'
Helm helm version '--template={{.Version}}' | tr -d 'v'
Java java -version 2>&1 | head -n '1' | sed -e 's/_.*//; s/.*"//'
Julia julia --eval 'print(VERSION)'
Kotlin kotlin -version | sed -e 's/.*n //; s/-.*//'
Lua lua -e 'io.write(_VERSION:gsub("Lua ", ""))'
Nim nim --version | head -n '1' | cut -d ' ' -f '4'
NodeJS node -e 'console.log(process.versions.node)'
OCaml ocaml --version | cut -d ' ' -f '5'
Perl perl -e "printf '%vd', $^V"
PHP php -r 'print(phpversion());'
Pulumi pulumi version 2>'/dev/null'
PureScript purs --version
Python python -c 'import platform; print(platform.python_version())'
R R --version | head -n '1' | cut -d ' ' -f '3'
Red red --version
Ruby ruby -e 'print RUBY_VERSION'
Rust rustc --version | cut -d ' ' -f '2'
Scala scala -e 'print(util.Properties.versionNumberString)'
Swift swift -version | head -n '1' | cut -d ' ' -f '3'
Vagrant vagrant --version | cut -d ' ' -f '2'
VLang v version | cut -d ' ' -f '2'
Zig zig version

🎲 Other

Module Shell script
AWS #TODO
Azure #TODO
Conda printf "$CONDA_DEFAULT_ENV"
Docker Context #TODO
Dotnet #TODO
Google Cloud (gcloud) #TODO
Kubernetes #TODO
Mercurial Branch #TODO
Nix-shell #TODO
OpenStack #TODO
Package Version #TODO
Singularity #TODO
Sudo #TODO
Terraform #TODO
VCSH #TODO